start new:
tmux
start new with session name:
tmux new -s myname
// example | |
User = Backbone.Model.extend({ | |
url: function() { | |
var origUrl = Backbone.Model.prototype.url.call(this); | |
return origUrl + (origUrl.charAt(origUrl.length - 1) == '/' ? '' : '/'); | |
} | |
}); |
# | |
# Working with branches | |
# | |
# Get the current branch name (not so useful in itself, but used in | |
# other aliases) | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
# Push the current branch to the remote "origin", and set it to track | |
# the upstream branch | |
publish = "!git push -u origin $(git branch-name)" |
#!/usr/bin/env bash | |
# | |
# This is sp, the command-line Spotify controller. It talks to a running | |
# instance of the Spotify Linux client over dbus, providing an interface not | |
# unlike mpc. | |
# | |
# Put differently, it allows you to control Spotify without leaving the comfort | |
# of your command line, and without a custom client or Premium subscription. | |
# |
def pretty_time_delta(seconds): | |
sign_string = '-' if seconds < 0 else '' | |
seconds = abs(int(seconds)) | |
days, seconds = divmod(seconds, 86400) | |
hours, seconds = divmod(seconds, 3600) | |
minutes, seconds = divmod(seconds, 60) | |
if days > 0: | |
return '%s%dd%dh%dm%ds' % (sign_string, days, hours, minutes, seconds) | |
elif hours > 0: | |
return '%s%dh%dm%ds' % (sign_string, hours, minutes, seconds) |
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash |
DEBUG=True | |
SOUTH_TESTS_MIGRATE = True | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. | |
'NAME': 'geo', # Or path to database file if using sqlite3. | |
'USER': 'postgres', # Not used with sqlite3. | |
'PASSWORD': 'postgres', # Not used with sqlite3. | |
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)import urllib.request | |
import urllib.error | |
import json | |
import re | |
import cmd | |
import html | |
def getTeletekstPage(page): | |
url = 'http://teletekst-data.nos.nl/json/%s' % (page) | |
res = urllib.request.urlopen(url) |