Skip to content

Instantly share code, notes, and snippets.

Adam Grant adamjgrant

  • Software Engineer
View GitHub Profile
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
adamjgrant / _about.md
Last active Jul 8, 2017
Machine learning excerpts
View _about.md

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

View 01_Easy_Live_Editing.md

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
(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)
@adamjgrant
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 = array.select { |n| n < pivot }
right = array.select { |n| n >= pivot }
@adamjgrant
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(:*) }
end
# 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
@adamjgrant
adamjgrant / dice.rb
Created Oct 31, 2016
Ruby Koans Dice Game
View dice.rb
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
# * A set of three numbers (other than ones) is worth 100 times the
# number. (e.g. three fives is 500 points).
View api__user-table.js
var user_table_api = function(_$) {
return {
create: function(user) {
_$.router.create(user).then(
function() {
if (_$.config.verbose) {
$_(".alert").html("User created successfully");
}
},
You can’t perform that action at this time.