start new:
tmux
start new with session name:
tmux new -s myname
try: | |
from django.utils.deprecation import MiddlewareMixin | |
except ImportError: | |
MiddlewareMixin = object | |
class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
""" | |
Ignore Accept-Language HTTP headers | |
// example | |
User = Backbone.Model.extend({ | |
url: function() { | |
var origUrl = Backbone.Model.prototype.url.call(this); | |
return origUrl + (origUrl.charAt(origUrl.length - 1) == '/' ? '' : '/'); | |
} | |
}); |
#!/usr/bin/php | |
<?php | |
/* Transmission to Deluge export script | |
* | |
* Transmission - transmission-gtk 2.77 (14031) | |
* Deluge - deluge: 1.3.6 | |
* Script - PHP 5.4.14 (cli) | |
* | |
* How to use this script; | |
* 1) Run `php trans_to_deluge.php` and make sure there aren't any errors. |
# generate your private key, put the public key on the server you will be connecting to | |
ssh-keygen -t rsa -f ./my_key | |
# generate the password/secret you will store encrypted in the .travis.yml and use to encrypt your private key | |
cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret | |
# encrypt your private key using your secret password | |
openssl aes-256-cbc -pass "file:./secret" -in ./my_key -out ./my_key.enc -a | |
# download your Travis-CI public key via the API. eg: https://api.travis-ci.org/repos/travis-ci/travis-ci/key |
from selenium import webdriver | |
def before_all(context): | |
context.browser = webdriver.Firefox() | |
def after_all(context): | |
context.browser.quit() |
# -*- coding: utf-8 -*- | |
''' | |
Tricky admin -> xadmin merger. | |
Alex Moiseenko aka IMDagger. | |
''' | |
import logging | |
import types | |
from functools import wraps, update_wrapper | |
from django.http import HttpRequest | |
from django.contrib.admin import ModelAdmin |
I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.
package main | |
import ( | |
"log" | |
"math" | |
) | |
func Round(val float64, roundOn float64, places int ) (newVal float64) { | |
var round float64 | |
pow := math.Pow(10, float64(places)) |
import asyncio | |
@asyncio.coroutine | |
def waiting(r): | |
print("hello from waiting -", r) | |
yield from asyncio.sleep(2) | |
print("bye from waiting -", r) | |
return r | |