This file contains 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
# Originally developed by Thomas Parslow http://almostobsolete.net | |
# Extended by Urban Skudnik urban.skudnik@gmail.com | |
# | |
# Just a work in progress and adapted to what I need right now. | |
# It does uploads (via a file-like object that you write to) and | |
# I've started on downloads. Needs the development version of Boto from Github. | |
# |
This file contains 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
object GameOfLife { | |
type Pos = (Int, Int) | |
type Alive = Boolean | |
type Weight = Int | |
type Grid = Map[Pos, Alive] | |
def findNeighbours(pos: Pos): List[Pos] = { | |
val T = List(-1 , 0, 1) | |
for {x <- T; y <- T if !(x == 0 && y == 0)} yield (x + pos._1, y + pos._2) | |
} |
This file contains 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
from collections import defaultdict | |
# take 1 | |
def abczzz(limit, abc={3: "fizzz", 5: "buzzz"}): | |
d = defaultdict(str) | |
table = [] | |
for k, v in abc.items(): | |
table += [{k*x:v for x in range(limit)}] | |
for t in table: | |
for k, v in t.items(): |
This file contains 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
#!/usr/bin/env bash | |
MYCOMMAND='while [ true ]; do sleep 1; echo "beje"; done' | |
# This will take down the whole process tree on ctrl+c | |
trap "exit" INT TERM | |
trap "kill 0" EXIT | |
while true; do | |
sleep 1; |
This file contains 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
## A _very_ naive comparison of set([list of numbers]) vs {list of numbers} | |
# set([list of numbers]) vs {list of numbers} results in ~25% performance improvements on simple lists for {list of numbers}: | |
==== | |
> python -m timeit "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}" | |
1000000 loops, best of 3: 0.911 usec per loop | |
> python -m timeit "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}" | |
1000000 loops, best of 3: 0.901 usec per loop | |
> python -m timeit "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}" | |
1000000 loops, best of 3: 0.924 usec per loop |
This file contains 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
let channels = rec { | |
pkgs = import <nixpkgs> {}; | |
pkgs-unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {}; | |
}; | |
in with channels; | |
let dependencies = rec { | |
_pip = pkgs.python36Packages.pip; | |
_virtualenv = pkgs.python36Packages.virtualenv; | |
_ipython = pkgs.python36Packages.ipython; |
This file contains 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 Data.Char | |
import Data.List | |
import Data.Map (Map) | |
import qualified Data.Map.Strict as Map | |
{-| | |
--------------------------- | |
| 1 | 2 ABC | 3 DEF | | |
___________________________ | |
| 4 GHI | 5 JKL | 6 MNO | |
This file contains 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
{ config, pkgs, ... }: | |
let channels = rec { | |
pkgs-unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { config.allowUnfree = true; }; | |
pkgs-master = import (fetchTarball https://github.com/NixOs/nixpkgs/archive/master.tar.gz) { config.allowUnfree = true; }; | |
}; | |
in with channels; | |
... |
This file contains 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
{ config, pkgs, ... }: | |
let channels = rec { | |
pkgs-unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { config.allowUnfree = true; }; | |
pkgs-master = import (fetchTarball https://github.com/NixOs/nixpkgs/archive/master.tar.gz) { | |
config.allowUnfree = true; | |
overlays = [ | |
(self: super: { | |
firefox-master = super.firefox.override { | |
browserName = "firefox"; |
OlderNewer