Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@korya
korya / postal-codes.json
Last active August 26, 2015 15:59 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$" }, { "Note":
@korya
korya / README.md
Created June 26, 2014 14:18
Quick Node.js webserver for serving static content

Many times I need just to run a simple webserver in a specific directory. That is the solution I came up with.

Installation

Put the files somewhere and then:

$ npm install

Usage

@korya
korya / Docker-tricks.md
Last active August 29, 2015 14:04
Docker tricks

Exploring container's FS

First get a name or an ID of your docker container:

DOCKERID=$(docker ps | awk ...)

Quick and dirty

@korya
korya / gist:fcbea22b4f96ce9b14a2
Last active August 29, 2015 14:04
Convert git repo subhistory to a separate git repo
  1. Clone

    git clone <remote-url> <dir>
    cd <dir>
    git remote rm origin
  2. Find a start commit of your history

START=git log | grep ...

@korya
korya / func-inv.go
Last active August 29, 2015 14:05
Golang's invariance
/* "Invariance" in golang
* http://play.golang.org/p/ww9UEEKI97
*
* Output:
* > B::foo
* > C::foo
* > B::foo
* > B::bar
* > B::bar
*/
@korya
korya / main.go
Last active August 29, 2015 14:06
goamz + fakes3 example
package main
import (
"fmt"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/s3"
)
var (
@korya
korya / Xmodmap.md
Last active August 29, 2015 14:07
Back to Ubuntun From MacOS
  1. In order to make our life easier: set Caps Lock key to behave as Escape.
  2. In order to keep Emacs-style shortcuts (Ctrl-O, Ctrl-W, etc.): keep left Ctrl key behaviour as is.
  3. In order to bring MacOS-style shortcuts (Cmnd-C, Cmnd-V, etc.): set left Alt key to behave as Ctrl_L.
  4. In order to have access to Alt_L button: set left Super key to behave as Alt_L.

The .Xmodmap file:

! Set 
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
@korya
korya / boot2docker.md
Last active August 29, 2015 14:07
A way to run parrallels/boot2docker

A way to run parrallels/boot2docker suggested by @YungSang suggests in Parallels/vagrant-parallels#115:

Init

$ cd ~/dev/boot2docker
$ vagrant plugin install vagrant-parallels
$ vagrant init parallels/boot2docker
$ vagrant up --provider parallels
$ export DOCKER_HOST="tcp://`vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"`:2375"
-- http://www.redisgreen.net/library/ratelimit.html
-- Return Value: 1 if rate limit exceeded, otherwise 0
-- Keys: 1
-- 1. A key to use as an expiring counter, e.g. "ratelimit:ip:127.0.0.1"
-- Args: 2
-- 1. Maximum number of calls
-- 2. Amount of time in ms
local cnt = redis.call('INCR', KEYS[1])
@korya
korya / howto.md
Created January 20, 2015 01:59
Debugging Redis Lua scripts