Skip to content

Instantly share code, notes, and snippets.

View robinsloan's full-sized avatar

Robin Sloan robinsloan

View GitHub Profile
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "abcd"
CONSUMER_SECRET = "abcd"
OAUTH_TOKEN = "abcd"
OAUTH_TOKEN_SECRET = "abcd"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
@robinsloan
robinsloan / pushing-fragments.js
Created April 13, 2020 02:55
Just a little snippet for Tom
F.visibleTextFragments.push(newFragment);
let text = `<p>`;
if (F.visibleTextFragments.length > 0) {
let visibleText = F.visibleTextFragments.reduce(function(visibleFragments, thisFragment) {
return visibleFragments + thisFragment;
});
text += `<span class="visible">${visibleText}</span>`;
}
-- note: 256 numbers in table
local notes = { 4.8, 4.0, 4.1, 4.4, 4.8, 5.0, 5.1, 5.4, 5.8, 6.0, 6.1, 6.4, 6.8, 7.0, 7.1, 7.4, 7.8, 7.4, 7.1, 7.0, 6.8, 6.4, 6.1, 6.0, 5.8, 5.4, 5.1, 5.0, 4.8, 4.4, 4.1, 4.0, 4.5, 4.7, 4.8, 4.1, 4.5, 4.7, 4.8, 5.1, 5.5, 5.7, 5.8, 6.1, 6.5, 6.7, 6.8, 7.1, 7.5, 7.1, 6.8, 6.7, 6.5, 6.1, 5.8, 5.7, 5.5, 5.1, 4.8, 4.7, 4.5, 4.1, 4.8, 4.7, 4.8, 4.0, 4.1, 4.4, 4.8, 5.0, 5.1, 5.4, 5.8, 6.0, 6.1, 6.4, 6.8, 7.0, 7.1, 7.4, 7.8, 7.4, 7.1, 7.0, 6.8, 6.4, 6.1, 6.0, 5.8, 5.4, 5.1, 5.0, 4.8, 4.4, 4.1, 4.0, 4.5, 4.7, 4.8, 4.1, 4.5, 4.7, 4.8, 5.1, 5.5, 5.7, 5.8, 6.1, 6.5, 6.7, 6.8, 7.1, 7.5, 7.1, 6.8, 6.7, 6.5, 6.1, 5.8, 5.7, 5.5, 5.1, 4.8, 4.7, 4.5, 4.1, 4.8, 4.7, 4.5, 4.8, 4.2, 4.4, 4.5, 4.8, 5.2, 5.4, 5.5, 5.8, 6.2, 6.4, 6.5, 6.8, 7.2, 7.4, 7.5, 7.4, 7.2, 6.8, 6.5, 6.4, 6.2, 5.8, 5.5, 5.4, 5.2, 4.8, 4.5, 4.4, 4.2, 4.8, 4.7, 4.0, 4.4, 4.5, 4.7, 5.0, 5.4, 5.5, 5.7, 6.0, 6.4, 6.5, 6.7, 7.0, 7.4, 7.5, 7.7, 7.5, 7.4, 7.0, 6.7, 6.5, 6.4, 6.0, 5.7, 5.5, 5.4, 5.0, 4.7, 4.5, 4.4, 4.0, 4.5, 4.8, 4.0, 4.4
@robinsloan
robinsloan / delete-dms.js
Created September 1, 2019 00:32
Code for a bookmarklet to more quickly delete DMs via the Twitter web interface.
// This doesn't work THAT well, but it kinda works... so!
// 1. Make a new bookmarklet with the code below as its URL
// 2. Go to mobile.twitter.com/messages
// 2a. This won't work on the "normal" DM pages, i.e., not the mobile site
// 3. Select a thread
// 3a. So, you see a list of messages now, right?
// 4. Click this bookmarklet :)
// 5. repeat as many times as necessary!
// 6. I think this probably goes without saying, but this doesn't delete your DMs from the *other* person's account. But it does make them invisible to, e.g., someone who hacks your account. Not that that's ever going to happen.
// 6a. It's definitely going to happen
@robinsloan
robinsloan / ruby_zip.rb
Created October 24, 2012 01:47
Ruby zip
# zip two collections together then iterate in lockstep
first_names = "Clark", "Bruce", "Diana"
last_names = "Kent", "Wayne", "Troy"
first_names.zip(last_names) do |first, last|
puts "#{first} #{last}"
end
@robinsloan
robinsloan / gif-to-vid.sh
Created August 28, 2017 21:16
FFMPEG command to convert GIF to proper MP4
ffmpeg -i this_here.gif -vcodec h264 -y -pix_fmt yuv420p that_there.mov
@robinsloan
robinsloan / autoresponder.txt
Created November 30, 2018 19:21
Twitter DM autoresponder
# First,
twurl authorize --consumer-key YOUR_CONSUMER_KEY --consumer-secret YOUR_CONSUMER_SECRET
# Then,
twurl -A 'Content-type: application/json' -X POST /1.1/direct_messages/welcome_messages/new.json -d '{"welcome_message": {"name": "autoresponder", "message_data": {"text": "Hi! I am not currently checking DMs. You can email me instead 👉 YOUR EMAIL HERE"}}}'
# In the response, note the id of the returned welcome message object, because you'll need it in a moment.
@robinsloan
robinsloan / bad-fax-filter.svg
Created September 12, 2018 17:08
I like the look of this
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import subprocess as sp
import numpy as np
import signal
from PIL import Image
### TUKEY WINDOW
# https://leohart.wordpress.com/2006/01/29/hello-world/
def tukey_window(window_length, alpha=0.5):
# Special cases
from PIL import Image
import glob
import numpy as np
### TUKEY WINDOW
### https://leohart.wordpress.com/2006/01/29/hello-world/
def tukey_window(window_length, alpha=0.5):
# Special cases
if alpha <= 0: