Skip to content

Instantly share code, notes, and snippets.

View spencermountain's full-sized avatar

spencer kelly spencermountain

View GitHub Profile
@spencermountain
spencermountain / demo.html
Last active June 21, 2023 17:24
Video thumbnails on-the-fly with ffmpeg+express
<!-- view random screenshot of a video, without any javascript -->
<img src="http://localhost/api/thumb?id=foobar.mp4">
@spencermountain
spencermountain / update-fork-alias
Last active March 1, 2019 15:57
Keeping a fork up-to-date
#add this function to ~/.bashrc or ~/.bash_profile
# each time you clone a fork, add the original as 'upstream'
# git remote add upstream git://github.com/REPO_ORG/REPO_NAME.git
# (thanks https://gist.github.com/CristinaSolana/1885435)
# keeps a fork up-to-date from the main repo
function update-fork() {
git fetch upstream
git pull upstream master
errors:
key 34.8026083,135.5382721 must not contain '.'
Pitt Town, New South Wales - cannot read length, politics/population.js:8
... 1:30pm
took 4.6 hours
@spencermountain
spencermountain / csp-test.js
Last active February 28, 2018 18:32
test a content-security-policy
//add a new content-security-policy to the page
function addTag(content){
var meta = document.createElement('meta');
meta.httpEquiv = "Content-Security-Policy";
meta.content = content
document.getElementsByTagName('head')[0].appendChild(meta);
}
//try to add a <script> tag
function addScript(src) {
hKRib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgrnerFBSQMUN4kUjy9k/FGTbiIjoZZYxRr2m+kZtoE2UKp3BheWxvYWTFAvp7ImJvZHkiOnsia2V5Ijp7ImVsZGVzdF9raWQiOiIwMTIwYWU3N2FiMTQxNDkwMzE0Mzc4OTE0OGYyZjY0ZmM1MTkzNmUyMjIzYTE5NjU4YzUxYWY2OWJlOTE5YjY4MTM2NTBhIiwiaG9zdCI6ImtleWJhc2UuaW8iLCJraWQiOiIwMTIwYWU3N2FiMTQxNDkwMzE0Mzc4OTE0OGYyZjY0ZmM1MTkzNmUyMjIzYTE5NjU4YzUxYWY2OWJlOTE5YjY4MTM2NTBhIiwidWlkIjoiYThlMmQ2ZDFlOGE3MmQwMGJkNzExZTZkYWYyMTE5MTkiLCJ1c2VybmFtZSI6InNwZW5jZXJtb3VudGFpbiJ9LCJzZXJ2aWNlIjp7Im5hbWUiOiJnaXRodWIiLCJ1c2VybmFtZSI6InNwZW5jZXJtb3VudGFpbiJ9LCJ0eXBlIjoid2ViX3NlcnZpY2VfYmluZGluZyIsInZlcnNpb24iOjF9LCJjbGllbnQiOnsibmFtZSI6ImtleWJhc2UuaW8gZ28gY2xpZW50IiwidmVyc2lvbiI6IjEuMC4xNyJ9LCJjdGltZSI6MTQ3NTY4MjI0MSwiZXhwaXJlX2luIjo1MDQ1NzYwMDAsIm1lcmtsZV9yb290Ijp7ImN0aW1lIjoxNDc1NjgyMjIwLCJoYXNoIjoiNmYzZDczZWY0M2RhOTIwMmMxMTU1ZjRlNGE2MDg0NDFmNmU4YzU1NzEwZTJhYmVkMmE1ZDk1ZDcyNWE5NGEwZGE1ZmMxNmIxNjFmMWE1OTA1Yzk0NjU3NjA1NWRhZTIxOGNmZTE3MGRmMDAzZWJiYjU1MDRmOWE2NmZiZDBkOGYiLCJzZXFubyI6NjY1MjE1fSwicHJldiI6IjI2Y2YwYzgxNDg0ZDQ4ZGNmZjE5
@spencermountain
spencermountain / top 100 results from 11 seasons of friends transcripts.js
Created April 26, 2016 18:54
spotter results from nlp.txt('').topics() - april 26, 2016
[ { count: 2523, text: 'ross' },
{ count: 1922, text: 'joey' },
{ count: 1876, text: 'god' },
{ count: 1411, text: 'rachel' },
{ count: 1348, text: 'guy' },
{ count: 1345, text: 'monica' },
{ count: 991, text: 'chandler' },
{ count: 640, text: 'phoebe' },
{ count: 430, text: 'pheeb' },
{ count: 385, text: 'rach' },
zgrep -v 'www.w3.org\/1999\/02\/22-rdf-syntax-ns#type\|www.w3.org\/2000\/01\/rdf-schema#label\|music.release\|music.track\|music.recording\|22-rdf-syntax-ns#type\|book.book_edition\|book.isbn\|common.notable_for\|film_crew_gig\|tv.tv_series_episode\|type.namespace\|type.content\|type.permission\|common.topic.notable\|type.object.key\|key\/authority\|type.object.permission\|type.type.instance\|dataworld.freeq\|common.licensed_object' ~/freebase-rdf-latest.gz | sed 's/<http:\/\/rdf\.freebase\.com\/ns\/\([^>]*\)>/\1/g;s/<http:\/\/www\.w3\.org\/[^#]*//g' > ~/much_smaller_dump.tsv
@spencermountain
spencermountain / gist:a26a9636f5b2a4c38c60
Created June 26, 2015 16:12
remove atom contextmenu defaults
#remove things from contextmenu
ban_menus= {
"Undo":true
"Split Up":true
"Correct Spelling":true
}
atom.contextMenu.itemSets.forEach (o)->
if o.selector.match(/(atom-text-editor|atom-pane)/)
if ban_menus[o.items[0].label] || ban_menus[(o.items[1]||{}).label]
o.items=[];
@spencermountain
spencermountain / gist:696fdc5e7f48035b83e4
Created May 1, 2015 22:42
sentence segmentation v0.3.9 from nlp_compromise
//(Rule-based sentence boundary segmentation) - chop given text into its proper sentences.
// Ignore periods/questions/exclamations used in acronyms/abbreviations/numbers, etc.
// @spencermountain 2015 MIT
var sentence_parser = function(text) {
var sentences = [];
//first do a greedy-split..
var chunks = text.split(/(\S.+?[.\?!])(?=\s+|$|")/g);
//honourifics
var abbrevs = ["jr", "mr", "mrs", "ms", "dr", "prof", "sr", "sen", "corp", "rep", "gov", "atty", "supt", "det", "rev", "col", "gen", "lt", "cmdr", "adm", "capt", "sgt", "cpl", "maj", "miss", "misses", "mister", "sir", "esq", "mstr", "phd", "adj", "adv", "asst", "bldg", "brig", "comdr", "hon", "messrs", "mlle", "mme", "op", "ord", "pvt", "reps", "res", "sens", "sfc", "surg"];
//common abbreviations
@spencermountain
spencermountain / gist:e11224480072b518bb1f
Created June 1, 2014 00:29
Line() primitive for famo.us
class Line
constructor: (@options)->
if !@options.container
@options.container= mainContext
@s= new Surface({
size:[0, @options.width||2]
properties:{
"background-color":@options.color||"pink"
}