start new:
tmux
start new with session name:
tmux new -s myname
| from collections import OrderedDict | |
| from itertools import repeat, izip | |
| alist = ["a", "b", "c", "a"] | |
| n = repeat(None) | |
| print(list(OrderedDict(izip(alist,n)))) |
| 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", |
| """ | |
| 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, |
| Verifying that +dangayle is my Bitcoin username. You can send me #bitcoin here: https://onename.io/dangayle |
| 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()] |
| 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 |
| """Twitter bot that tweets a random line from a file. | |
| Uses Twisted to periodically select a random line from an input file, | |
| and Twython to post it to Twitter using your credentials. | |
| Usage: python twitterbot.py file.txt, where each line in file.txt is | |
| a single sentence terminated by a newline ('\n'). | |
| """ | |
| import sys |
| 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 |
| def hello_world(name=None): | |
| if name is None: | |
| name = "world" | |
| print("Hello {name}".format(name=name)) | |
| hello_world("Dan") |