Skip to content

Instantly share code, notes, and snippets.

View toolness's full-sized avatar

Atul Varma toolness

View GitHub Profile
@toolness
toolness / youtube-to-mp3-Dockerfile
Last active August 29, 2015 14:04
A Dockerfile that makes it easy to convert youtube videos to mp3's
FROM ubuntu:14.04
MAINTAINER Atul Varma
RUN printf '\ndeb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse' >> /etc/apt/sources.list
RUN printf '\ndeb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse' >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y libav-tools libavcodec-extra-54 python python-pip
RUN pip install --upgrade youtube_dl
@toolness
toolness / get-flagged-message-info.js
Last active August 13, 2017 19:46
Outputs a JSON stream of information about all your flagged IMAP messages.
var _ = require('underscore');
var Imap = require('imap');
var JSONStream = require('JSONStream');
var USER = process.env.USER;
var PASSWORD = process.env.PASSWORD;
var HOST = process.env.HOST;
var MS_PER_DAY = 1000 * 60 * 60 * 24;
var MAX_AGE = MS_PER_DAY * 90;
@toolness
toolness / pbpaste.py
Last active August 29, 2015 14:01
ctypes-based Python version of OS X's pbpaste command for Windows.
import sys
import ctypes
# This is adapted from code found via:
# http://nullege.com/codes/search/ctypes.windll.user32.OpenClipboard
ctypes.windll.user32.OpenClipboard(0)
pcontents = ctypes.windll.user32.GetClipboardData(1) # 1 is CF_TEXT
data = ctypes.c_char_p(pcontents).value
ctypes.windll.user32.CloseClipboard()
@toolness
toolness / minicade.yaml
Created April 19, 2014 12:36
Sample Minicade Gist
title: My Example Minicade-in-a-gist
games:
- title: Flyswat
description: Swat the fly before time runs out!
url: http://toolness.github.io/fancy-friday/example/game-01.html
@toolness
toolness / https-proxy-with-sni.js
Last active January 23, 2022 12:39
HTTPS proxy server with SNI
var fs = require('fs');
var crypto = require('crypto');
var http = require('http');
var https = require('https');
var async = require('async');
var httpProxy = require('http-proxy');
var _ = require('underscore');
var UID = 1000;
var PASSPHRASE = process.env.PASSPHRASE || null;
@toolness
toolness / programming-questions.md
Last active August 29, 2015 13:57
My response to a friend's questions about programming

Following is a response to a friend's questions about the following:

If Ruby and Python are programming languages, what is HTML? Is that a programming language too?

If you are writing HTML, are you not writing in Ruby or Python?

Or is HTML the base and then Ruby or Python somehow builds on it?

All of the websites explain how to use all of this stuff but none of them explain the very basics of what this all means and how the pieces fit together.

@toolness
toolness / crypter.js
Created March 24, 2014 12:13
Noobish attempt at making a password-based encryption/decryption mini-library in node.
var crypto = require('crypto');
var CIPHERS = {
'aes256': {
blockSize: 128 / 8,
keySize: 256 / 8
}
};
var HASHES = {
@toolness
toolness / mentor-resume.md
Last active January 3, 2016 05:59
My mini-resume/portfolio for being a volunteer tech mentor.

Hello! My name is Atul Varma. I generally go by the name toolness on the internet, whether it's the domain name of my [blog][], or my username on [twitter][] and [github][].

I'm currently doing design and engineering work with the Mozilla Foundation's Webmaker Community Team, and am looking for volunteer mentor opportunities.

Biography

During my time at Kenyon College, I served as a Mathematics and Computer Science tutor.

After graduating in 2001 with a B.S. in Mathematics, I moved to Chicago and became a certified adult literacy tutor at [The Blue Gargoyle][]; I also tutored mathematics and basic digital literacy to adults and teens.

@toolness
toolness / CYOA-Example.html
Last active December 31, 2015 13:19
Super simple example of a Choose Your Own Adventure in a single webpage, with support for editing in jsbin or thimble+togetherjs.
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>CYOA Example</title>
<body>
<section id="start">
<h2>Page 1</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
@toolness
toolness / httpsify.js
Last active December 28, 2015 19:39
Simple node script to serve HTTP resources on whitelisted domains over HTTPS.
var http = require('http');
var url = require('url');
var PORT = process.env['PORT'] || 3000;
var MAX_SIZE = process.env['MAX_SIZE'] || 524288;
var EXTRA_CONTENT_TYPES = (process.env['CONTENT_TYPES'] || '').split('');
var HOSTS = (process.env['HOSTS'] || '').split(' ');
var ORIGIN_HOSTS = (process.env['ORIGIN_HOSTS'] || '').split(' ');
var CACHE_SECONDS = 'CACHE_SECONDS' in process.env
? parseInt(process.env['CACHE_SECONDS']) : 600;