Search By Label
const number = 123456.789;console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number));
// Expected output: "123.456,79 €"// The Japanese yen doesn't use a minor unit
console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number));
// Expected output: "¥123,457"// Limit to three significant digits
console.log(new Intl.NumberFormat('en-IN', { maximumSignificantDigits: 3 }).format(number));
// Expected output: "1,23,000"
Enumerable#cycle
offers an easy way to either repeat a certain pattern n times or just to switch between two predefined states. irb> array = [1, 2, 3] => [1, 2, 3] irb> array.cycle(3).to_a => [1, 2, 3, 1, 2, 3, 1, 2, 3]
irb> button = ['on', 'off'].cycle => # irb> button.next => "on" irb> button.next => "off"
export EDITOR=
bundle open
wicked_pdf
gem is:template: 'folder/file', formats: [:html]
// Start the timer console.time('myTimer');// Simulate a time-consuming operation
for (let i = 0; i < 1000000; i++) {
// Some code here
}// Stop the timer and display the elapsed time in milliseconds
console.timeEnd('myTimer');
-- set a global variable SET my_var = 42;-- use the global variable
SELECT * FROM my_table WHERE column = my_var;-- unset the global variable RESET my_var;
-- Let's say we update some data in a table. UPDATE my_table SET column1 = 'new_value' WHERE id = 42;-- Now, we want to know how many rows got changed and if there's a unique ID for the last row.
GET DIAGNOSTICS rows_affected = ROW_COUNT, last_oid = RESULT_OID;-- We can print these values to see what happened.
RAISE NOTICE 'Rows affected: %, Last OID: %', rows_affected, last_oid;
CREATE OR REPLACE FUNCTION example_function() RETURNS void AS $$ BEGIN -- Some code here -- Raise a notice message RAISE NOTICE 'This is a notice message: %', 'Additional data'; -- More code here END; $$ LANGUAGE plpgsql;
:not
pseudo selector is useful for styling a group of elements while leaving the last (or specified) element unstyled.One Two Three Four
.css-not-selector-shortcut { display: flex; }
ul { padding-left: 0; }
li { list-style-type: none; margin: 0; padding: 0 0.75rem; }
li:not(:last-child) { border-right: 2px solid #d2d5e4; }
Did you know that in Ruby 3.1.3 and prior some regexps could take a long time to process?
Don't believe me? Try running this in a 3.1.3 irb console:
`/^a*b?a*$/ =~ "a" * 50000 + "x"`
Your system will halt for like 10 seconds before returning no matches. This is the basis for ReDoS (Regexp Denial of Service) attacks.
Thankfully, Ruby 3.2.0 has fixed this and the same regexp gets resolved in 0.003 seconds. They also added a `Regex.timeout` global option which would prevent your app from falling victim to ReDoS attacks!