Skip to content

Instantly share code, notes, and snippets.

View davej's full-sized avatar
💭
Working on @ToDesktop

Dave Jeffery davej

💭
Working on @ToDesktop
View GitHub Profile
@davej
davej / delete_all_tweets.py
Last active March 27, 2024 03:12
This script will delete all of the tweets in a specified account.
# -*- coding: utf-8 -*-
"""
This script will delete all of the tweets in the specified account.
You may need to hit the "more" button on the bottom of your twitter profile
page every now and then as the script runs, this is due to a bug in twitter.
You will need to get a consumer key and consumer secret token to use this
script, you can do so by registering a twitter application at https://dev.twitter.com/apps
@requirements: Python 2.5+, Tweepy (http://pypi.python.org/pypi/tweepy/1.7.1)
@davej
davej / twitter_sync.py
Created May 26, 2009 00:51
Keeps your followers and friends in sync
# -*- coding: utf-8 -*-
"""
This script will follow all those who follow you and unfollow those who
unfollow you. Basically it keeps your followers and friends in sync.
You will need to get a consumer key and consumer secret token to use this
script, you can do so by registering a twitter application at http://twitter.com/apps
@requirements: Python 2.5+, Tweepy (https://github.com/joshthecoder/tweepy)
@author: Dave Jeffery
# !/bin/sh
# I stole this little script from somewhere but can't remember where, sorry for not including credit.
for i in "rte.ie" "facebook.com" "reddit.com" "tb4.fr" "bbc.co.uk" "boards.ie" "google.com"
do
for j in "4.2.2.2" "8.8.8.8" "208.67.222.222" "89.101.160.4" # Tests Level 3, Google Public DNS, OpenDNS, UPC default DNS.
do
echo $j $i `dig @$j $i | grep Query | awk -F ":" '{print $2}'`
done
done
@davej
davej / Nginx configuration for gunicorn
Created September 10, 2010 19:46
Nginx configuration for gunicorn
# Simple Version
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/example.log;
location / {
proxy_pass http://127.0.0.1:1337;
}
@davej
davej / hosts on Mac OS X
Created September 10, 2010 19:47
Redirecting DNS by editing /etc/hosts on Mac OS X
# /etc/hosts
127.0.0.1 local.domain
123.123.123.123 www.domain.com
# In the Mac OS X terminal type:
dscacheutil -flushcache
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
var cookie = client.request.headers.cookie;
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
redis.get(sid, function(err, data) {
fn(err, JSON.parse(data));
});
};
// usage
@davej
davej / DRY.js
Created January 26, 2012 01:14 — forked from EGreg/DRY
Asynchronous cache failover example
function cacheOrDB (id, callback) {
asynchronousCache.get("id:"+id, function(err, myThing) {
if (myThing == null) {
asynchronousDB.query("SELECT * from something WHERE id = "+id, function(err, myThing) {
callback(err, myThing);
});
} else {
callback(err, myThing);
}
});
@davej
davej / gist:1680278
Created January 26, 2012 01:21 — forked from EGreg/gist:1678415
Asynchronous loop issues illustrative example
// Illustrative case
// YEAH -- ILLUSTRATIVE OF THE FACT THAT YOU CAN ISSUE PARALLEL QUERIES TO THE DATABASE INSTEAD OF SERIAL ONES LIKE A DUMB THREADED IMPLEMENTATION THAT IS INFERIOR FOR DOING WEB SERVERS
function (recentBlogPostIds, callback) { // obviously you need this, but use callback instead of return
var results = [], // Use array not object
, len = recentBlogPostIds.length; // Cache length since we'll be using it more than once
for (var i = 0; i < len; i++) {
var blogPostId = recentBlogPostIds[i];
@davej
davej / basecamp-todos-to-blimp-goals.py
Created January 22, 2013 20:17
A simple script to copy a Basecamp classic todo list over to Blimp as a goal with tasks
"""
A simple script to copy a Basecamp classic todo list
over to Blimp as a goal with tasks
@author: Dave Jeffery
@requirements:
pip install git+git://github.com/nowherefarm/basecamp.git
pip install blimp
"""
define [
'base-ctrl'
], (BaseCtrl) ->
class AppController extends BaseCtrl
@register()
@inject('$scope')
init: ->
@$scope.foo = "bar"