Skip to content

Instantly share code, notes, and snippets.

View zaa's full-sized avatar

Aleksandr Zhuravlev zaa

View GitHub Profile
% License: NewBSD.
-module(escape_html).
-author(zaa@ikato.com).
-export([escapeHTML/1, selftest/0]).
escapeHTML(Str) ->
escapeHTML(Str, []).
escapeHTML([], Acc) ->
lists:reverse(Acc);
@zaa
zaa / license
Created January 27, 2010 10:33 — forked from defunkt/license
#!/bin/sh -e
# Usage: license
# Prints an MIT license
#
# $ license > COPYING
year=`date "+%Y"`
cat <<EOF
Copyright (c) $year Alexander Zhuravlev
Permission is hereby granted, free of charge, to any person obtaining
@zaa
zaa / README.MD
Created December 7, 2011 03:59 — forked from wynst/README.MD
A Thor Task to unwatch *all* Github watched repositories (excluding owned) and optionally export to delicious.

A Thor Task to unwatch all Github watched repositories (excluding owned) and optionally export to delicious.

Sorry Github, for I have sinned. I use the Watch feature as a bookmarker.

Install required gems:

gem install thor rest-client

Use it as such:

@zaa
zaa / patch-keep-slave-data.diff
Created December 22, 2011 09:45 — forked from ambroff/patch-keep-slave-data.diff
Allow setting up replication without purging data in the slave first.
diff --git a/redis.conf b/redis.conf
index 44fb536..505cb6e 100644
--- a/redis.conf
+++ b/redis.conf
@@ -150,6 +150,13 @@ slave-serve-stale-data yes
#
# repl-timeout 60
+# When setting up replication, the slave will purge the current data set before
+# loading the data sync from the master. Setting this will prevent that from
@zaa
zaa / gist:2430311
Created April 20, 2012 17:04 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@zaa
zaa / gist:9523526
Last active May 13, 2018 07:13
Fetch AWS instance prices (per month)
curl -s 'http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/ec2/linux-od.js' | sed -e 's/callback(//;s/^)$//' | jq '[.config.regions[] | select(.region == "us-west") |.instanceTypes[].sizes[] | {key: (.size), value: ((.valueColumns[0].prices.USD|tonumber)*720)} ] | from_entries'
@zaa
zaa / ets-memory-usage
Created March 29, 2014 23:12
Erlang: ETS memory usage top
lists:usort(
fun({_, M1} , {_, M2}) -> M1 > M2 end,
[{ets:info(Tab, name), ets:info(Tab, memory)*erlang:system_info(wordsize)} || Tab <- lists:sort(ets:all())]
).

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@zaa
zaa / keybase.md
Created May 14, 2014 22:56
keybase.md

Keybase proof

I hereby claim:

  • I am zaa on github.
  • I am zaa (https://keybase.io/zaa) on keybase.
  • I have a public key whose fingerprint is BBB0 31B9 6039 04FE 5564 4D89 3758 2AB0 46F2 AB3D

To claim this, I am signing this object: