Skip to content

Instantly share code, notes, and snippets.

View dsamarin's full-sized avatar

Devin Samarin dsamarin

View GitHub Profile
@dsamarin
dsamarin / all-orders-placed-by-a-customer.sql
Created October 9, 2019 08:31 — forked from dan81989/all-orders-placed-by-a-customer
Let’s say we want to find all orders placed by a particular customer. We can do this by joining the customers and orders tables together using the relationship established by the customer_id key.
SELECT order_date, order_amount
FROM customers
JOIN orders
ON customers.customer_id = orders.customer_id
WHERE customer_id = 3
@dsamarin
dsamarin / graycode.js
Last active August 29, 2015 14:27 — forked from silentmatt/graycode.js
JavaScript functions to convert to/from binary-reflected Gray codes
Number.toGrayCode = function(n) {
if (n < 0) {
throw new RangeError("cannot convert negative numbers to gray code");
}
return n ^ (n >>> 1);
};
Number.fromGrayCode = function(gn) {
if (gn < 0) {
throw new RangeError("gray code numbers cannot be negative");
@dsamarin
dsamarin / pipes.sh
Last active December 12, 2015 05:49
#!/bin/bash
# The author of the original script is unknown to me. The first entry I can
# find was posted at 2010-03-21 09:50:09 on Arch Linux Forums (doesn't mean the
# poster is the author at all):
#
# https://bbs.archlinux.org/viewtopic.php?pid=728932#p728932
#
# I, Yu-Jie Lin, made a few changes and additions:
#
# -p, -R, and -C
@dsamarin
dsamarin / lolwat.js
Created August 18, 2011 10:58 — forked from mathiasbynens/lolwat.js
Fun with v8’s Number#toString bug
var fs = require('fs');
var repl = require('repl');
console.log("Loading dictionary...");
var words = fs.readFileSync("/usr/share/dict/american-english-small", "ascii");
var wordlist = {};
var regex = /[a-z]{4,}/g;
var match;