Skip to content

Instantly share code, notes, and snippets.

View leetrout's full-sized avatar
🎸

Lee Trout leetrout

🎸
View GitHub Profile
@snelson
snelson / interfaces
Created March 7, 2010 22:04
OpenVPN on Ubuntu 9.10 Server and Rackspace Cloud Server
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# Uncomment this and configure after the system has booted for the first time
auto eth0
iface eth0 inet static
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@staydecent
staydecent / hash_password.php
Created June 10, 2011 20:18
Django's password hashing ported to PHP
<?php
private function set_password($raw_password) {
/*
Sets the password to a string of random sha1 salt
and encrypted password.
Separated by '$'
*/
$salt = substr(sha1(genRandomString().genRandomString()), 0, 5);
$hash = sha1($salt.$raw_password);
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@leetrout
leetrout / aREADME.rst
Created February 28, 2012 02:45
Clone all your github repos into a local directory

USAGE

python ghclone.py

Follow the prompts

Notes

@stringfellow
stringfellow / spine_modelresource.py
Created May 18, 2012 13:19
Spinejs - django-tastypie integration base ModelResource class
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
from tastypie.resources import ModelResource
class SpineFrontedResource(ModelResource):
"""A base model resource for spine-fronted models.
* Bins the 'id' that spine sends.
* Removes 'meta' from the list, returns only objects.
@fernandoaleman
fernandoaleman / gist:5083680
Last active October 17, 2023 12:02
How to update VirtualBox Guest Additions with vagrant
# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class AttrDict(dict):
def __init__(self, arg=(), **kwargs):
items = arg.items() if isinstance(arg, (dict, )) else arg
for key, value in items:
self[key] = self.fromdict(value)
for key, value in kwargs.items():
self[key] = self.fromdict(value)
@artyom
artyom / rpc-tls-client.go
Last active October 9, 2023 15:44
Go RPC over TLS.You have to create the following keys: certs/client.crt, certs/client.key, certs/server.crt, certs/server.key. client.crt and server.crt should be signed with ca.crt, which should be concatenated to both client.crt and server.crt. It's easier to do with easy-rsa: http://openvpn.net/index.php/open-source/documentation/howto.html#pki
package main
import (
"crypto/tls"
"crypto/x509"
"log"
"net/rpc"
)
func main() {
@sourcec0de
sourcec0de / nxql_usda.md
Created October 11, 2013 23:16
Nutritionix NXQL and USDA Items

USDA Getting Started

Example NXQL Queries

// returns items that are not restaurants and nf_serving_weight_grams is not null
// includes usda_fields in the results so items that contain those fields will return
// fields.usda_fields
{
  "fields":["item_name","brand_name","keywords","usda_fields"],
  "query":"celery",