Skip to content

Instantly share code, notes, and snippets.

View rgorsuch's full-sized avatar

Ryan Gorsuch rgorsuch

View GitHub Profile
package main
import (
"fmt"
"log"
"net/http"
)
const response = `{
"queryID": 42,
package main
// This is a one-file boil-down of github.com/k0kubun/pp + github.com/mattn/go-colorable.
// It can do terminal coloring and pretty printing for ease of use in repl.it
// Paste it into a file in your repl.it and then use it like this, no import necessary.
//
// func main() {
// pp.Println(struct{ message, whom string }{
// message: "Hello", whom: "World"},
// )
package http_test
import (
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"testing"
@rgorsuch
rgorsuch / encoding-video.md
Created February 1, 2018 18:18 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
function count_rows {
# Count the rows in all the tables in a sqlite db
# Usage: count_rows my-sqlite.db
DB=$1
TABLES=`echo "SELECT name FROM sqlite_master WHERE type='table';" | sqlite3 $DB`
for TABLE in $TABLES
do
printf "%10d %s\n" `echo "SELECT count(*) from $TABLE;" | sqlite3 $DB` $TABLE
"===============================================================================
"VIM Configuration File
"==============================================================================
set printoptions=paper:letter,syntax:n
syntax on
"turn on doxygen syntax hilighting. Works for C, C++, C#, and IDL files.
let g:load_doxygen_syntax=1
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
#!/usr/bin/perl -w
# Tiny script to color your output green for stdout, red for stderr
# Use it like this: color [app] [args ...]
use strict;
use warnings;
use Term::ANSIColor;
use IPC::Open3;
no warnings 'once';
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; This script has a special filename and path because it is automatically
; launched when you run the program directly. Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it. You can have as many .ahk
; files as you want, located in any folder. You can also run more than
; one ahk file simultaneously and each will get its own tray icon.
function trunclog {
# Truncate a log file and leave N lines of tail remaining.
if [ "$*" = "" ]
then
echo "Usage: trunclog [lines] [log-file]"
else
REQUESTED_LINES=$1
LOG=$2
TEMP=/tmp/`basename $LOG`.tmp.$$
tail -$REQUESTED_LINES $LOG > $TEMP