This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screen -d -m -S screen_with_cat /bin/cat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function create_venv() { | |
test -d env || virtualenv env | |
source ./env/bin/activate | |
pip install -q -U pip | |
} | |
function babel_from_pip() { | |
echo "==================================================" | |
echo "Running tests with Babel 2.1.1, installed with pip" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"af": { | |
"name": "Afrikaans", | |
"formula": "n != 1", | |
"plurals": 2, | |
"cases": [ | |
"one", | |
"other" | |
], | |
"examples": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_type(root, old_type, new_type): | |
""" | |
Helper function to recursively walk through the datastructure and change old_type to new_type | |
""" | |
def _match(obj, **kwargs): | |
return isinstance(obj, old_type) | |
def _replace(obj, **kwargs): | |
return new_type(obj) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Jump hash with linear probing | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
JumpHash(N) maps consistently integer values onto the range [0, N), which can | |
be used to map users (by their user ids) to servers (by their indexes in | |
a configuration file, for example). | |
There is one important limitation of the hash, which affects its | |
use: buckets (servers) must be numbered sequentially, and it's important |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
session=wahoo | |
[first] | |
cmd='echo Wahoo!' C-m | |
[second] | |
cmd='echo Heya.' C-m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> bitmapist.mark_unique('foo', 1) | |
>>> bitmapist.mark_unique('foo', 1000) | |
>>> bitmapist.mark_unique('bar', 1) | |
>>> list(bitmapist.UniqueEvents('foo') & ~bitmapist.UniqueEvents('bar')) | |
[] | |
>>> list(bitmapist.UniqueEvents('foo') ^ bitmapist.UniqueEvents('bar') & bitmapist.UniqueEvents('foo')) | |
[1000] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$utc = new DateTimeZone('UTC'); | |
$user_tz = new DateTimeZone('Europe/Moscow'); | |
// current time in UTC | |
date_default_timezone_set('UTC'); | |
$datetime = new DateTime(); | |
// convert current time to user's local time | |
$datetime->setTimezone($user_tz); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export TZ='Europe/Moscow' | |
exec open -na "Google Chrome" --args "--user-data-dir=$HOME/chrome-profile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytz | |
import os | |
def guess_timezone(city): | |
""" | |
Take the city name and try to guess the timezone | |
""" | |
tz_map = {tz.split('/')[-1].lower(): tz for tz in pytz.all_timezones} | |
try: |