This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| var input = document.getElementById('myfileinput'); | |
| var files = input.files; | |
| var file = files[i]; | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open('post', '/path/to/destination', true); | |
| xhr.onreadystatechange = function() { | |
| if (this.readyState != 4) { return; } | |
| // request finished - handle response | |
| }; |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| <!DOCTYPE html> | |
| <!-- Based off of the infinity symbol from http://css-tricks.com/examples/ShapesOfCSS/ --> | |
| <html> | |
| <head><title>CSS Eyeball</title> | |
| <style> | |
| #eyeball { | |
| position: relative; | |
| width: 140px; | |
| height: 100px; | |
| } |
| [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) |
| 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 |
| #!/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 & |
| package main | |
| import "fmt" | |
| func main() { | |
| foo := 4 | 2 | 16 | |
| foo &= (511 ^ 4) | |
| fmt.Printf("%b", foo) | |
| } |
| // 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{ |
| 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; }()) |
| 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) |