Skip to content

Instantly share code, notes, and snippets.

Adam Grant adamjgrant

  • Software Engineer
Block or report user

Report or block adamjgrant

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View debouncer
let debounce, debounceQueue;
debounceQueue = {};
debounce = function(fn, id, delay, args, that) {
delay = delay || 1000;
that = that || this;
args = args || new Array();
if (typeof debounceQueue[id] !== "object") {
debounceQueue[id] = new Object();
View sarcasm.js
var str = "%filltext:name=field 1%";
str.split("").map((char, index) => {
return index%2 == 0 ? char.toUpperCase() : char.toLowerCase();
View Mozart

Mozart 2

Mozart is new kind of tool for JavaScript Developers. It's an organizer, not a framework.

Mozart is not so much a library as it is a technique, but mozart.js makes it easy to employ it. This means it works well with other libraries of your chosing, like jQuery.

JavaScript gets messy fast.

View gist:086545e33aa6a9327ec1f72c9b019f31
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
$script = <<SCRIPT
sudo su
View ffmpeg.txt
/bin/nice -n 2 /mnt/data/tools/ffmpeg-linux/ffmpeg -progress /mnt/local/2638__p022/ffmpeg-progress.log -thread_queue_size 512 -loop 1 -framerate 30 -i "/mnt/data/static_assets/bg.png" \
-thread_queue_size 512 -framerate 30 -start_number 0 -i "/mnt/data/queue/2638/rendering/p004/0-60/movie_%05d.png" \
-thread_queue_size 512 -framerate 30 -start_number 100 -i "/mnt/data/queue/2638/rendering/p001/100-130/movie_%05d.png" \
-thread_queue_size 512 -framerate 30 -start_number 0 -i "/mnt/data/queue/2638/rendering/p002/0-60/movie_%05d.png" \
-thread_queue_size 512 -framerate 30 -start_number 92 -i "/mnt/data/queue/2638/rendering/p002/92-151/movie_%05d.png" \
-thread_queue_size 512 -framerate 30 -start_number 315 -i "/mnt/data/queue/2638/rendering/p003/315-329/movie_%05d.png" \
-thread_queue_size 512 -framerate 30 -start_number 0 -i "/mnt/data/queue/2638/rendering/p004/0-60/movie_%05d.png" \
-filter_complex "[0:v] setpts=PTS-STARTPTS [base_seg]; \
[1:v] setpts=PTS-STARTPTS-30 [inp_0]; \
[2:v] setpts=PTS-STARTPTS-10 [in
adamjgrant /
Last active Jul 8, 2017
Machine learning excerpts

Machine learning playtime

I've been playing with a Machine Learning script to see what it can do with various kinds of inputs. The results are below. If you want to try yourself, check out my repo.

If you have some text you want to give me to try out, I'd be happy to spin up a VM for you and post the results here. However I'd ask that you pitch in a few bucks first as the VMs can take a day or more to run completely at $0.25 - $1.00 per hour

If you're interested, ping me on twitter


Stupidly simple live editing

This is a nice and simple script I like to use when I'm heads down on front end development. All this does is automatically reload the page every 2 seconds.

What I love most about this is that I can just open any text editor, and just double click on the html file being edited to view in a browser. No building, cloning, or plugins needed and it works on any OS.

View url.regex
adamjgrant / sorts.rb
Last active Nov 4, 2016
Quicksort, mergesort, etc.
View sorts.rb
require 'benchmark'
def quick_sort(array)
return array if array.size <= 1
pivot ||= array.shift
left = { |n| n < pivot }
right = { |n| n >= pivot }
adamjgrant / cross_multiply.rb
Last active Nov 1, 2016
Interview Question: Cross Multiply
View cross_multiply.rb
def cross_multiply(a, b)
shorter, longer = a.size < b.size ? [a, b] : [b, a]
shorter.cycle.take(longer.size).zip(longer).map { |n| n.reduce(:*) }
# Given two arrays with different, non-zero lengths, multiply each item at their same index between arrays.
# After reaching the end of the shorter array but before the end of the longer array,
# start back at the beginning of the shorter array.
# Example
You can’t perform that action at this time.