Skip to content

Instantly share code, notes, and snippets.

View uskudnik's full-sized avatar

Urban Škudnik uskudnik

View GitHub Profile
@uskudnik
uskudnik / glacier.py
Created August 24, 2012 11:18 — forked from almost/glacier.py
Amazon Glacier from Python. Based on Boto, will contribute to Boto when it's a little more finished if it's any good at that point :)
#!/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.
#
@uskudnik
uskudnik / GameOfLife.sc
Created November 10, 2014 01:24
Game of Life in Scala
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)
}
@uskudnik
uskudnik / abcbuzz.py
Last active September 10, 2015 20:10
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():
#!/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;
@uskudnik
uskudnik / building-set-perf.py
Last active August 2, 2016 12:23
set([list of nubmers]) vs. {list of numbers}
## 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
@uskudnik
uskudnik / nixos-on-dell-9560.org
Created June 17, 2017 23:29 — forked from grahamc/nixos-on-dell-9560.org
NixOS on a Dell 15" 9560 with the 4K screen.
@uskudnik
uskudnik / default.nix
Created June 23, 2017 18:43
example-python-nix-env.nix
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;
@uskudnik
uskudnik / algebraic-types-phone.hs
Created June 26, 2017 20:35
smsing like in the old days
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 |
@uskudnik
uskudnik / conf.nix
Last active November 29, 2017 13:26
configuration.nix
{ 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;
...
@uskudnik
uskudnik / configuration.nix
Created December 8, 2017 18:04
Aliasing with overlays
{ 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";