Skip to content

Instantly share code, notes, and snippets.

View rileyjshaw's full-sized avatar
💭
Riley is typing…

Riley Shaw rileyjshaw

💭
Riley is typing…
View GitHub Profile
@rileyjshaw
rileyjshaw / eq.js
Created April 18, 2019 06:04
ascii equalizer based on https://twitter.com/jake_albaugh/status/1118611365508337665; trying to fit this into a single tweet (280 characters)
n=(l='▁▂▃▄▅▆▇█'.split(''),x=new AudioContext(),d=new Uint8Array(16),a=x.createAnalyser()).fftSize=32
navigator.mediaDevices.getUserMedia({audio:1}).then(s=>{x.createMediaStreamSource(s).connect(a)
setInterval(_=>{a.getByteFrequencyData(d)
location.hash=[...d].map(v=>l[0|v/n]).join('')},n)})
@rileyjshaw
rileyjshaw / story_clip.sh
Last active May 6, 2018 17:13
Split a longer video into 15 second clips (and rotate it, add audio) using FFmpeg for an Instagram story
# I'm sure there's a simple way to do this without intermediate files but :shrug:
# transpose=1 rotates 90 degrees.
# fade=in:120:60 adds a fade from 4s - 5s, since it's 30fps.
# the fade is placed there because later we crop the video and audio 4s: -ss 00:00:04. -shortest clips the output to the end of the video, not the whole song duration.
ffmpeg -i IMG_5965.mov -vf "transpose=1,fade=in:120:60" output_rotated.mov && ffmpeg -i output_rotated.mov -i ~/Downloads/soul_vibration.mp3 -ss 00:00:04 -shortest output_audio.mov && ffmpeg -i output_audio.mov -codec copy -shortest -c copy -map 0 -segment_time 00:00:10 -f segment -reset_timestamps 1 output%03d.mov && rm output_rotated.mov output_audio.mov
@rileyjshaw
rileyjshaw / linear-gradint.frag
Created March 29, 2018 22:23
GLSL linear gradient
// Author: rileyjshaw
// Title: Linear gradient
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
@rileyjshaw
rileyjshaw / instagram-caption-scrape.js
Created March 19, 2018 07:01
Grab and print all captions from your Instagram feed.
// A bunch of tools exist for downloading Instagram photos
// (eg. chrome.google.com/webstore/detail/olkpikmlhoaojbbmmpejnimiglejmboe)
// but not as many grab your captions. This is quick and dirty, in the spirit of
// https://gist.github.com/rileyjshaw/953b3aba4c48e34b0069152f5fc21e4c.
// In your browser of choice, open up the Web Console and paste in the following.
// You might need to change some `querySelector` calls to match the Instagram web
// client's current markup.
// Fragile! Based on a generated classname. Replace this with whatever selector
@rileyjshaw
rileyjshaw / find-unused-functions.sh
Created June 14, 2017 21:24
Used this for a quick audit at work. Not comprehensive, but uncovered some good leads nevertheless.
for match in $(egrep -roi '([_a-z])+: function' javascript | cut -d : -f 1-2); do
file=`echo $match | cut -d : -f 1`
fn=`echo $match | cut -d : -f 2`
count=`grep -r $fn javascript | wc -l`
if [[ $count -lt 2 ]]; then
echo "$file:$fn"
fi
done
@rileyjshaw
rileyjshaw / delete-tumblr-posts-100-at-a-time.js
Created June 13, 2017 17:12
Lets you delete every post from your tumblr pretty quickly, unless you have a *lot* of them
/**
* STEP 1: Go to https://www.tumblr.com/mega-editor/<your-blog-name>
* STEP 2: Open your developer console
* STEP 3: Paste this snippet in
* STEP 4: Hit enter twice
* STEP 5: Repeat from STEP 2 until everything is deleted
*
* Deletes 100 at a time due to tumblr restrictions.
*/
Array.from(document.querySelectorAll('.overlay')).slice(-100).forEach(el => el.click());
@rileyjshaw
rileyjshaw / unfave.rb
Created June 13, 2017 14:59 — forked from robinsloan/unfave.rb
Unfave script, because why not??
#!/usr/bin/env ruby
require "rubygems"
require "twitter"
require "json"
require "faraday"
# things you must configure
TWITTER_USER = "your_username"
# get these from dev.twitter.com
@rileyjshaw
rileyjshaw / langoliers.rb
Created June 13, 2017 14:58 — forked from robinsloan/langoliers.rb
Tweet delete script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@rileyjshaw
rileyjshaw / bad-but-spunky-fb-wall-deleter.js
Last active June 17, 2017 19:38
Might get you part-way to deleting your Facebook wall?
// In Chrome, go to your profile page. Open the Developer Tools Console
// (cmd + alt + j) and click the mobile phone button in the top left ("Toggle
// device toolbar"). I did this because it's easier to get around whatever
// guards are in place without worrying about hover states, etc.
//
// I chose "iPhone 5" in the device menu at the top of the browser window. That
// might be important, but probably not. I only ran this once ¯\_(ツ)_/¯
//
// Refresh the page, scroll down so you can see your posts, paste this into the
// console, hit enter, and enjoy the show for 20 seconds until it comes to a
@rileyjshaw
rileyjshaw / fix_notation.py
Created May 29, 2017 20:55
Find scientific notation in a file and switch each occurrence to floats. Used for Hacklab TO's laser cutter.
#!/usr/bin/env python
"""Find scientific notation in a file and switch each occurrence to floats."""
import argparse
import re
# Example usage: `./fix_notation.py hologram.ngc hologram_fixed.ngc -p 8`
parser = argparse.ArgumentParser(description='Find scientific notation in a file and switch each occurrence to floats.')
parser.add_argument('input_file', type=str)
parser.add_argument('output_file', type=str)