Skip to content

Instantly share code, notes, and snippets.

View dangayle's full-sized avatar

Dan Gayle dangayle

View GitHub Profile
@dangayle
dangayle / tmux.md
Created March 14, 2014 18:41 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@dangayle
dangayle / hello_world.py
Created May 28, 2014 16:59
Basic html/css/python
def hello_world(name=None):
if name is None:
name = "world"
print("Hello {name}".format(name=name))
hello_world("Dan")
test_string = '''<!--[youtube id="vlmGknvr_Pg"]-->'''
def youtube(id):
return "https://www.youtube.com/watch?v={id}".format(id=id)
# >> https://www.youtube.com/watch?v=vlmGknvr_Pg
@dangayle
dangayle / seq_range.py
Last active August 29, 2015 14:03
Paging function
def seq_range(page=1, prange=10):
"""Get a range of numbers for paging"""
start = page * prange - prange
end = start + prange - 1
print start, end

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
from django.db.models import Max
from blogs.models import Blog, BlogPost
def get_recent_posts():
"""Get latest blogpost for each blog."""
posts = []
blogs = Blog.objects.annotate(
most_recent=Max('blogpost__pubdate')
).order_by('-most_recent')[:Blog.objects.count()]
Verifying that +dangayle is my Bitcoin username. You can send me #bitcoin here: https://onename.io/dangayle
"""
I need to create a "most active" or "hottest" stories list, the main variables
being number of comments, number of views, and pubdate.
How do I take the three variables and create sort of weighted score, then sort on the score?
"""
stories = [
{ # 2 days old
"id": 1,
import datetime
import random
import Twython
from twisted.internet import task
from twisted.internet import reactor
TIMEOUT = datetime.timedelta(hours=1).seconds
twitter = Twython("YOUR API KEY",
"YOUR API SECRET",
@dangayle
dangayle / unique.py
Created October 29, 2014 03:56
unique list
from collections import OrderedDict
from itertools import repeat, izip
alist = ["a", "b", "c", "a"]
n = repeat(None)
print(list(OrderedDict(izip(alist,n))))