This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a bookmark in safari with this as the address | |
javascript: (function() {var video; document.querySelectorAll('video').forEach(function(vid) { if (!vid.paused) video = vid; }); if (video) { video.webkitSetPresentationMode('picture-in-picture') } })() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://news.ycombinator.com/item?id=9018756 | |
One of my favorite idioms lately for doing bulk updates without incurring lock contention is to chain CTEs, like so: | |
with candidate_rows as ( | |
select id | |
from table | |
where conditions | |
limit 1000 | |
for update nowait | |
), update_rows as ( | |
update table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspiration: http://stackoverflow.com/a/19868697/1221591 | |
select | |
* | |
from | |
events, | |
json_array_elements(events.raw->'attendees') as attendees | |
where | |
attendees->>'email' = '[email protected]'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build a hash of keys to use for lookup. | |
def build_key(x, encrypt=true) | |
chars = ('a'..'z').to_a | |
{}.tap do |key| | |
chars.each_with_index do |char, idx| | |
if(encrypt) | |
key[char] = chars[(idx + x) % 26] # rotate x clicks forward | |
else | |
key[char] = chars[(idx - x) % 26] # rotate x clicks backwards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cms/path_helper' | |
module Cms | |
module PathHelper | |
def cms_index_path_for(resource, options={}) | |
options[:only_path] = false | |
cms_index_url_for(resource, options) | |
end | |
def cms_index_url_for(resource, options={}) |