Skip to content

Instantly share code, notes, and snippets.

@insom
insom / gist:1585630
Created January 9, 2012 23:29
One push gunicorn deploy from via git
aaron@aaron-laptop:~$ mkdir newsite
aaron@aaron-laptop:~$ cd newsite
aaron@aaron-laptop:~/newsite$ git init
Initialized empty Git repository in /home/aaron/newsite/.git/
aaron@aaron-laptop:~/newsite$ cat > newsite.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
@insom
insom / listener.coffee
Created January 18, 2012 16:11
A Hubot HTTP -> talking script
module.exports = (robot) ->
robot.router.post "/hubot/say", (req, res) ->
room = req.body.room
message = req.body.message
robot.logger.info "Message '#{message}' received for room #{room}"
user = robot.userForId 'broadcast'
user.room = room
user.type = 'groupchat'
robot.send user, "#{message}"
res.writeHead 200, {'Content-Type': 'text/plain'}
@insom
insom / mod_space_core.c
Created February 8, 2012 22:12
Space Core Apache Module
/* ====================================================================
* Copyright (c) 2012 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
@insom
insom / grouped-commits.coffee
Created February 9, 2012 23:43
Use Github V3 API to display grouped commits by person by day
U = require 'underscore'
H = require 'scoped-http-client'
T = require 'util'
H.create('https://api.github.com/')
.header('accept', 'application/json')
.path('repos/insom/pymogile/commits')
.get() (e, r, b) ->
v = U.map JSON.parse(b).filter((item) -> item['committer']),
(item) -> [item['url'], item['commit']['committer']['name'],
item['commit']['committer']['date'].substring(0,10)]
@insom
insom / enc.rb
Created March 9, 2012 23:23
ENC to convert JSON to YAML
#!/usr/bin/env ruby
require 'net/http'
require 'JSON'
require 'YAML'
url = "http://localhost:8000/hosting/json/#{ARGV[0]}/"
r = Net::HTTP.get_response(URI.parse(url))
o = JSON.parse(r.body)
puts o.to_yaml
@insom
insom / .daz.bashrc
Created May 14, 2012 09:59
Daz-inspired .bashrc
alias ss="ssh $1.manc.iws-hosting.co.uk"
# Color codes
RED='\[\033[01;31m\]'
GREEN='\[\033[01;32m\]'
YELLOW='\[\033[01;33m\]'
BLUE='\[\033[01;34m\]'
PURPLE='\[\033[01;35m\]'
CYAN='\[\033[01;36m\]'
WHITE='\[\033[01;37m\]'
NIL='\[\033[00m\]'
@insom
insom / glacier.py
Created August 22, 2012 09:51 — forked from almost/glacier.py
Amazon Glacier from Python. Based on Boto, will contribute to Boto when it's a little more finished if it's any good at that point :)
# Thomas Parslow http://almostobsolete.net
# Just a work in progress and adapted to what I need right now.
# It does uploads (via a file-like object that you write to) and
# I've started on downloads. Needs the development version of Boto from Github.
#
# Example:
#
# glacierconn = GlacierConnection(AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY)
# writer = GlacierWriter(glacierconn, GLACIER_VAULT)
# writer.write(somedata)
@insom
insom / libvirtnovnc.py
Created November 8, 2012 11:30
Libvirt NoVNC Proxy
#!/usr/bin/python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Based on work Copyright (c) 2012 Openstack, LLC.
import Cookie
import os
import socket
import sys
import websockify
""""Create "The Matrix" of binary numbers scrolling vertically in your terminal.
original code adapted from juancarlospaco:
- http://ubuntuforums.org/showpost.php?p=10306676
Inspired by the movie: The Matrix
- Corey Goldberg (2013)
Requires:
@insom
insom / moon.py
Created April 26, 2013 16:14
Emoji Phases of the Moon in Python
import sys, time
while True:
for i in range(311, 319):
print "\r", eval("u'\U0001f%d'" % i), "",
sys.stdout.flush()
time.sleep(0.1)