Skip to content

Instantly share code, notes, and snippets.

@kurrik
kurrik / about.md
Created August 9, 2011 15:11 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@kurrik
kurrik / .tmux.conf
Last active April 18, 2020 03:23
Remote .tmux.conf (handles nesting, different colors)
# Install:
# curl https://gist.githubusercontent.com/kurrik/ec0a83cf568b9c16b8ce08dd407adf65/raw/.tmux.conf > ~/.tmux.conf
#
# Instructions:
# When nested, use an extra `ctrl-b` to issue commands to the nested session.
# E.g. to go to the next window `ctrl-b ctrl-b ctrl-n`
# Colors
set -g default-terminal "xterm-256color"
@kurrik
kurrik / twitter_ssl.rb
Created March 21, 2013 17:02
Demonstrating that Ruby sends invalid HTTPS requests unless use_ssl is explicitly set
require 'net/https'
# Returns {"errors":[{"message":"Bad Authentication data","code":215}]}
# Issues a HTTPS request to: GET https://api.twitter.com/1.1/users/show.json?user_id=33978
# Prints: Explicit SSL: #<Net::HTTPBadRequest:0x10b65f188>
uri = URI.parse("https://api.twitter.com/1.1/users/show.json?user_id=33978")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new(uri.request_uri)
@kurrik
kurrik / ffmpeg_convert.sh
Last active January 8, 2019 15:48
ffmpeg recipes
# Convert `mymovie.mp4` to `mymovie.mov`, re-encoding.
ffmpeg -i mymovie.mp4 mymovie.mov
# Change `mymovie.mov` to `mymovie.mp4`, without re-encoding.
ffmpeg -i mymovie.mov -vcodec copy -acodec copy mymovie.mp4
# Change `mymovie.mp4` to `mymovie-nosound.mp4`, dropping audio and re-encoding video to H.264 high quality
ffmpeg -i mymovie.mp4 -c:v libx264 -profile:v high -an mymovie-nosound.mp4
# Resize `mymovie.mp4` to `mymovie-480.mp4`, setting width to 480px and keeping aspect ratio
@kurrik
kurrik / input-time.js
Created October 8, 2012 17:12
Insert a time input into Twitter
document.body.appendChild(function() { var e = document.createElement("input"); e.type="time"; e.style.position="absolute"; e.style.top="0px"; e.style.left="0px"; e.style.zIndex="1000"; return e; }())
@kurrik
kurrik / anim.go
Created August 27, 2012 02:11
My favorite code from this weekend
// I couldn't have come up with this sober / well rested
const (
FACING_LEFT = 1 << iota
FACING_RIGHT = 1 << iota
PLAYER_STOPPED = 1 << iota
PLAYER_WALKING = 1 << iota
PLAYER_JUMPING = 1 << iota
)
a := map[int]*Animation{
@kurrik
kurrik / negate-bitmask.go
Created August 26, 2012 10:13
How to negate bits in a bitmask in Go
package main
import "fmt"
func main() {
foo := 4 | 2 | 16
foo &= (511 ^ 4)
fmt.Printf("%b", foo)
}
@kurrik
kurrik / proxy.sh
Created June 1, 2012 23:11
Proxy HTTPS requests through http://localhost:8080
#!/bin/bash
# From http://en.wikipedia.org/wiki/Netcat
# Proxy HTTPS requests through http://localhost:8080
# That way, Wireshark can sniff the traffic.
# Example usage:
# ./proxy.sh www.twitter.com
mkfifo tmp
mkfifo tmp2
nc -k -l 8080 > tmp < tmp2 &
@kurrik
kurrik / streaming.go
Created May 10, 2012 15:49
Hand-wavy streaming method
func (c *Connection) Read(output chan string) error {
var err error
if err = c.connect(); err != nil {
return err
}
defer c.conn.Close()
if err = c.readHeaders(); err != nil {
return err
}
err = c.readChunkedData(output) // Blocks until stream ends
@kurrik
kurrik / gist:1928436
Created February 28, 2012 01:43
Problem installing multiple libs from same github project
[kurrik@ ~/workspace/golibs/twurlrc] (master) 105$ goinstall github.com/kurrik/golibs/oauth1a
[kurrik@ ~/workspace/golibs/twurlrc] (master) 106$ goinstall github.com/kurrik/golibs/twurlrc
goinstall: github.com/kurrik/golibs/twurlrc: open /Users/kurrik/src/go/src/pkg/github.com/kurrik/golibs/twurlrc: no such file or directory ($GOPATH not set)