Skip to content

Instantly share code, notes, and snippets.

@almog
almog / gist:5280373
Created March 31, 2013 11:49
Tmux upgrade issue logs
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew upgrade tmux
------------------------------------------------
==> Upgrading 1 outdated package, with result:
tmux 1.8
==> Upgrading tmux
rm /usr/local/bin/tmux
rm /usr/local/etc/bash_completion.d/tmux
rm /usr/local/share/man/man1/tmux.1
==> Downloading http://sourceforge.net/projects/tmux/files/tmux/tmux-1.8/tmux-1.8.tar.gz
# requires socksify gem
require "socksify"
require 'socksify/http'
# use w/ OAuth2 like OAuth2::Client.new(id, secret, connection_opts: { proxy: 'socks://127.0.0.1:9050' })
class Faraday::Adapter::NetHttp
def net_http_class(env)
if proxy = env[:request][:proxy]
if proxy[:uri].scheme == 'socks'
Net::HTTP::SOCKSProxy(proxy[:uri].host, proxy[:uri].port)
@almog
almog / yad2_grid_captcha_decode
Last active January 1, 2016 11:29
Decode Yad2's captchas
wget "http://www.yad2.co.il/mailsecure.php" -O "captcha.jpg" && \
convert -white-threshold 55% captcha.jpg clean_captcha.jpg && \
tesseract clean_captcha.jpg captcha -psm 8 digits && \
cat captcha.txt
@almog
almog / gist:9780446
Created March 26, 2014 10:29
Extract streetnames from an OpenStreetMaps osm file
cat map*.osm \
| grep -P "k=\"addr:street\" v=\"(.*)\"" \
| sed -E "s/.*addr:street\" v=\"(.*)\".*/\1/" \
| sort -u > streets
@almog
almog / keybase.md
Created June 18, 2014 17:38
keybase.md

Keybase proof

I hereby claim:

  • I am almog on github.
  • I am almog (https://keybase.io/almog) on keybase.
  • I have a public key whose fingerprint is 773C DC54 43EC 3528 4219 B81B 3892 F02E AFC1 BD6F

To claim this, I am signing this object:

@almog
almog / selenium_cookies_to_mechanize_cookie_jar
Created July 12, 2014 17:12
Selenium cookies to Mechanize CookieJar
@almog
almog / mergesort
Created September 6, 2014 22:39
Haskell mergesort
mergesort :: (Ord a) => [a] -> [a]
mergesort [x] = [x]
mergesort xs = merge (mergesort (left xs)) (mergesort (right xs))
where left xs = take ((length xs) `div` 2) xs
right xs = drop ((length xs) `div` 2) xs
merge :: (Ord a) => [a] -> [a] -> [a]
merge [] ys = ys
merge xs [] = xs
merge (x:xs) (y:ys)
<html>
<p style="text-align: center">
<img src="http://eloquentjavascript.net/img/cat.png" style="position: absolute">
<img src="http://eloquentjavascript.net/img/hat.png" style="position: absolute">
</p>
<script>
var cat = document.querySelector("img[src*='cat']")
var hat = document.querySelector("img[src*='hat']")

Chapter 14 - Events

  • MouseEvent which property tells us which button was clicked (1 - left, 2 - middle, 3 - right).
  • Events in JS propagate outward only, is that true? Isn't there a inward propagation before that (like in good old Flash)?
  • What's the difference between stopPropagation and stopImmediatePropagation?
  • Is there a way to know if an event's default action was cancelled? Is there a way to un-cancel it?
  • "keydown" event is trigerred everytime the key repeats itself.
  • String.prototype.charCodeAt does what you think it does.
  • Keybord Events have shiftKey, ctrlKey, altKey, and metaKey flags.
  • "keypress" is fired after "keydown" but is only fired for keys that generate text-input.
  • String.fromCharCode translates a code into a charcter.
@almog
almog / -
Created October 12, 2014 19:24
ydl-mp3 () {
youtube-dl -o "%(title)s.%(ext)s" --extract-audio --audio-format=mp3 $1
}