Skip to content

Instantly share code, notes, and snippets.

View patrickhulce's full-sized avatar
😎
Live, eat, breathe JS

Patrick Hulce patrickhulce

😎
Live, eat, breathe JS
View GitHub Profile
@patrickhulce
patrickhulce / sockets.py
Created April 7, 2013 05:23
Working with web sockets.
#!/usr/bin/env python
import socket, threading, time, re
from base64 import b64encode
from hashlib import sha1
def handle(s,a):
print a
handshake_data = s.recv(4096)
print handshake_data
client_key = re.search("Sec-WebSocket-Key:\s+(.*?)[\n\r]+", handshake_data).groups()[0].strip()
@patrickhulce
patrickhulce / keymap.sublime-keymap
Created April 11, 2014 20:01
Sublime Home/End Fix OS X
[{
"keys": ["ctrl+a"],
"command": "move_cursor_beginning"
}, {
"keys": ["shift+ctrl+a"],
"command": "select_to_beginning"
}]
@patrickhulce
patrickhulce / server.py
Created February 18, 2015 04:16
304 Dummy Server
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
def echo(environ, start_response):
status = "304 Not Modified"
headers = [("Content-type", "application/json"), ("ETag", "asdf")]
start_response(status, headers)
return [""]
httpd = WSGIServer(('0.0.0.0', 80), WSGIRequestHandler)
httpd.set_app(echo)
@patrickhulce
patrickhulce / findkeys.sh
Last active July 10, 2023 10:09
Find all keys without a TTL in Redis
#!/bin/sh
redis-cli keys "*" | head -n $1 > keys.txt
cat keys.txt | xargs -n 1 -L 1 redis-cli ttl > ttl.txt
paste -d " " keys.txt ttl.txt | grep .*-1$ | cut -d " " -f 1 | redis-cli del
@patrickhulce
patrickhulce / app.js
Last active August 29, 2015 14:20 — forked from Mithrandir0x/gist:3639232
Angular Patterns
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@patrickhulce
patrickhulce / go.sh
Last active August 5, 2016 21:48
Basic Ubuntu Express Setup
# First, install Ubuntu 16 LTS (http://www.ubuntu.com/download/desktop) and open a terminal
# sudo means 'do this thing as the superuser', apt-get is a way to install software, nodejs and npm are two software packages you'll need
sudo apt-get install nodejs npm
# Creates the directory 'myfirstserver'
mkdir myfirstserver
# Changes the current directory to myfirstserver
cd myfirstserver
@patrickhulce
patrickhulce / ScalaStyle.md
Last active April 25, 2018 10:24
Scala Style Guide
@patrickhulce
patrickhulce / entry.js
Last active August 27, 2015 05:59
webpack intro
var webpack = require('webpack');
module.exports = {
entry: {
app: './entry.js'
},
output: {
path: __dirname,
publicPath: '/assets/',
filename: "[name].bundle.js"
@patrickhulce
patrickhulce / siege.sh
Created February 4, 2016 21:13
siege POST
siege -c 20 -d 0 -H "Content-Type: application/x-www-form-urlencoded" -g 'http://localhost:3000/endpoint POST mydata=foo'
siege -c 20 -d 0 -H "Content-Type: application/json" -g 'http://localhost:3000/endpoint POST {"key": "value"}'