Skip to content

Instantly share code, notes, and snippets.

@MayaLekova
MayaLekova / interleave.js
Created June 13, 2018 22:42
Interleaving of await and promises
async function pr(v) { console.log("pr(" + v + ")"); }
async function f() { for (var i = 0; i < 10; i++) { await pr(i); } return 0; }
function ct(v) { console.log("counter" + v); if (v > 0) Promise.resolve(v - 1).then(ct); }
ct(10); f();
@htp
htp / curl-websocket.sh
Last active November 13, 2024 12:46
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@thomasst
thomasst / migrate-redis.py
Created May 14, 2015 18:26
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@anaisbetts
anaisbetts / gh_unsub.rb
Last active December 25, 2015 18:09
Unsubscribe from all repos that you have not contributed to
#!/usr/bin/env ruby
require 'octokit'
pass_re = /^password: "(.*)"$/
token = `security find-generic-password -s "GitHub API Token" -g 2>&1 | grep "password"`.match(pass_re)[1]
c = Octokit::Client.new(:access_token => token)
user_login = c.user.login
@elidupuis
elidupuis / index.html
Created March 8, 2013 06:57
A CodePen by Eli Dupuis. Foundation block-grid - Foundation's block grids are awesome but they only work if all the elements are the same height. This SCSS snippet will allow the elements to be different heights. It works by simply clearing every nth element—based on how many columns you have. You can comment out the SCSS to see how the default …
<h1>Using both small and large grids</h1>
<ul class='small-block-grid-2 large-block-grid-4'>
<li><img src='http://placekitten.com/g/200/220' /></li>
<li><img src='http://placekitten.com/g/200/200' /></li>
<li><img src='http://placekitten.com/g/200/280' /></li>
<li><img src='http://placekitten.com/g/200/250' /></li>
<li><img src='http://placekitten.com/g/200/240' /></li>
<li><img src='http://placekitten.com/g/200/270' /></li>
<li><img src='http://placekitten.com/g/200/230' /></li>