Skip to content

Instantly share code, notes, and snippets.

View jamesadney's full-sized avatar

James Adney jamesadney

View GitHub Profile
@zyxar
zyxar / exercise.tour.go
Last active January 15, 2025 06:09
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@moraes
moraes / gist:2141121
Last active January 30, 2025 10:45
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@xianyunwuxin
xianyunwuxin / simple_websocket.py
Created December 7, 2011 01:54
Make Flask work with Tornado.websocket
from flask import Flask
app=Flask(__name__)
@app.route('/')
def index():
return """
<span id="now">loading<span>
<script type="text/javascript">
window.WebSocket=window.WebSocket || window.MozWebSocket || false;
@bdunagan
bdunagan / s3-delete-bucket.rb
Created November 21, 2011 17:23
s3-delete-bucket.rb: quickly delete large AWS S3 buckets using fog
#!/usr/bin/env ruby
# s3-delete-bucket.rb
# Fog-based script for deleting large Amazon AWS S3 buckets (~100 files/second)
# Forked from this excellent script: https://github.com/SFEley/s3nuke
require 'rubygems'
require 'thread'
require 'fog'
@lrvick
lrvick / flask_geventwebsocket_example.py
Created September 1, 2011 07:17
Simple Websocket echo client/server with Flask and gevent / gevent-websocket
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@bdarnell
bdarnell / fdserver.py
Created July 9, 2011 20:41
Demonstration of sharing file descriptors across processes
#!/usr/bin/env python
"""This is a demonstration of sharing file descriptors across processes.
It uses Tornado (need a recent post-2.0 version from github) and the
multiprocessing module (from python 2.6+). To run it, start one copy
of fdserver.py and one or more copies of testserver.py (in different
terminals, or backgrounded, etc). Fetch http://localhost:8000 and
you'll see the requests getting answered by different processes (it's
normal for several requests to go to the same process under light
load, but under heavier load it tends to even out).
anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@ludviglindblom
ludviglindblom / detect_full_screen.html
Created May 18, 2011 16:32 — forked from nathansmith/detect_full_screen.html
Detect full-screen mode for desktop browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Detect Full-Screen</title>
<style>
* {
font-family: sans-serif;
line-height: 1.5;
@dpogue
dpogue / netwatcher.py
Created January 30, 2011 10:10
Python script to watch for Avahi/Bonjour workstation broadcasts and present alerts using libnotify
#!/usr/bin/env python
import dbus, gobject, avahi, pynotify, time
from dbus import DBusException
from dbus.mainloop.glib import DBusGMainLoop
TYPE = '_workstation._tcp'
def service_resolved(*args):
name = args[5].split('.')[0]
ip = args[7]
#!/usr/bin/env python
import gtk, dbus, dbus.service, sqlite3
from dbus.mainloop.glib import DBusGMainLoop
DB_FILENAME = "/home/segphault/test.sqlite"
DBusGMainLoop(set_as_default=True)
class Notifier(dbus.service.Object):