Skip to content

Instantly share code, notes, and snippets.

View swinton's full-sized avatar
:bowtie:

Steve Winton swinton

:bowtie:
View GitHub Profile
@swinton
swinton / fizzbuzz.py
Created November 30, 2012 15:02
fizzbuzz.py
#!/usr/bin/env python
def fizzbuzz(start=1, stop=100):
for i in xrange(start, stop + 1):
if i % 3 == 0 and i % 5 == 0:
yield "FizzBuzz"
elif i % 3 == 0:
yield "Fizz"
elif i % 5 == 0:
#!/usr/bin/env python
import sys
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
'localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello', durable=True)
@swinton
swinton / mysql.txt
Last active December 12, 2015 10:19 — forked from johnantoni/mysql.txt
username: vagrant
password: vagrant
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev
sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf
change:
@swinton
swinton / Vagrantfile
Created February 13, 2013 15:23
Ugly way of opening a Django shell via a Vagrant command... there must be a better way?
Vagrant::Config.run do |config|
config.vm.box = "lucid64"
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
config.vm.host_name = "myvagrantbox"
# etc.
end
@swinton
swinton / gist:4985107
Created February 19, 2013 11:42
Add Ember-data to JSBin.com's libraries.
libraries.add({
text: 'My libraries',
requires: '//cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.1/ember.js', // optional
scripts: [
{ text: 'Ember Data 0.8.0', url: '//cdnjs.cloudflare.com/ajax/libs/ember-data.js/0.8.0-latest20121123/ember-data-latest.min.js' }
]
})
@swinton
swinton / star_now_playing.scpt
Created February 28, 2013 14:33
AppleScript to Star the current Spotify track. Requires [Starrify](https://github.com/swinton/starrify).
-- Check if Growl is running
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
-- Get URI of current Spotify track
tell application "Spotify"
set theTrack to current track
set theID to id of theTrack
set theName to name of theTrack
#!/usr/bin/env python
import sys
import time
import uuid
from functools import partial
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
@swinton
swinton / models.py
Created April 30, 2013 18:20
AccountMeta definition
class AccountMeta(models.Model):
key = models.CharField(max_length=240, db_index=True)
value = models.TextField()
account = models.ForeignKey(SocialAccount, related_name='meta')
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
unique_together=('account', 'key')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Simple Cloudant client, which is basically just a thin wrapper around the
requests.Session class.
Usage:
import cloudant
✎ v runworker
Warning: Permanently added 'emmasocial-streaming.local,192.168.33.43' (RSA) to the list of known hosts.
[*] Waiting for tasks. To exit press CTRL+C
INFO: 2013-05-15 22:00:20,434 - pika.adapters.base_connection - base_connection - _create_and_connect_to_socket - 174 - Connecting fd 3 to localhost:5672
================================================================================
INFO: 2013-05-15 22:00:20,477 - pika.adapters.blocking_connection - blocking_connection - _adapter_connect - 232 - Adapter connected
================================================================================
[*] Consuming from amq.gen-aO47xdlh0Zh5WQW-EQKz-w queue
[*] Consuming from start.consumer queue
INFO: 2013-05-15 22:00:30,770 - root - base - start_a_consumer - 417 - Starting consumer id steveWINton