Search By Label
-- 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!
Yesterday I implemented gzip request support in a project and noticed there are no gems for that. There's `Rack::Deflater` but that's for responses, not requests. Apparently, incoming gzipped payloads are uncommon. 🤷♀
Maybe an opportunity to write a new gem? 🤔
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
bin/rails db:environment:set RAILS_ENV="YOUR_ENVIRONMENT"
# Strings empty_string = "" non_empty_string = "Hello, world!"empty_string.empty? # => true
non_empty_string.empty? # => false# Arrays
empty_array = []
non_empty_array = [1, 2, 3]empty_array.empty? # => true
non_empty_array.empty? # => false# Hashes
empty_hash = {}
non_empty_hash = { name: "John", age: 30 }empty_hash.empty? # => true
non_empty_hash.empty? # => false
AVG(column_name)
ROUND(numeric_expression, number_of_decimal_places)
const person = { firstName: "John", lastName: "Doe", age: 30, address: { street: "123 Main St", city: "Anytown", state: "CA", zip: "12345", }, };console.dir(person);/* output: Object age: 30 address: Object city: "Anytown" state: "CA" street: "123 Main St" zip: "12345" firstName: "John" lastName: "Doe" */
'/'
even though you have another enable route '/welcome'
.app/controllers/application_controller.rb
:def after_sign_in_path_for(resource) welcome_path end
expresion operator ANY(subquery)
SELECT 3 = ANY (ARRAY[1, 2, 3, 4]); -- Returns TRUE SELECT 42 = ANY (SELECT column FROM some_table); -- Returns TRUE if 42 exists in the column SELECT 'apple' = ANY (VALUES ('banana'), ('apple'), ('cherry')); -- Returns TRUE
SELECT COALESCE(null, 42, 'Hello'); -- Returns 42
heroku apps
heroku apps:info --app example