Skip to content

Instantly share code, notes, and snippets.

@almog
almog / gcj_template
Last active April 25, 2021 11:12 — forked from ydm/gcj_template.py
Google Code Jam Python template
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import bisect
import collections
import collections.abc
import itertools
import math
import operator
@almog
almog / high_volume_sellers.js
Last active August 4, 2019 15:50
Extract list of high volume ebay sellers
// Run this script on a search page to get a list of large sellers (>1000)
// Use &_saslop=2&_sasl=<comma separated list to exclude sellers>
let sellerNameAndSalesMapper = (elem) => {
let sellerAndSalesText = elem.innerText.match(/Seller: ([-.\w]*) \(([\d,]*)\)/).slice(1)
return { seller: sellerAndSalesText[0], sales: parseInt(sellerAndSalesText[1].replace(',', ''), 10) }
}
let bigSellersFilter = (sellerAndSales) => {
const LARGE_SELLER_CAP = 1000
@almog
almog / selenium_cookies_to_mechanize_cookie_jar
Created July 12, 2014 17:12
Selenium cookies to Mechanize CookieJar
# 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: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
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFK3DOoBEADquhi1AuQFTlHn6RXO7ELZIQAVZAD7HuoGcyq+WhSU/Y5k17kX
rsXyxGKrWfE4rkICBPWPnOxolAYFAAfJKoh6hEO6cqip8tbWygJjH4VrjDRGyeXZ
jhQAKnzSte+QSmllprebx7CjFBMQJ4OFepo78Vjr9piGEfZZ9egu19ZsJBHlnS6J
aT+jaCO8dYErFIV7htK012f68DP0DHKmRj7NxQ5pqBbNY5aejWm7j0DoE6ckzxWC
GojsThXqJni6+oGuT/YkYELBuFDJLYOGG/yQGsqAZtfKl0paO8oZTqOk5B1Nt3Za
GbHDIjvSJAXYQO74lAxQV7fhcqr3c7mUB1X0d8OeU8Lb0/lmjxOe1JNyDZ1pd/k3
izkIi2nWEy8RCb8tgw/+Vb84sN4dQkZdNMs2TkPzmZuXk49LJ6mWK6iHD59hQFFW
@almog
almog / RayV_list
Last active August 29, 2015 14:07
RayV serendip list
# $ egrep -oh "href=\"https?://((\w+).)?(youtube|soundcloud|vimeo|dailymotion|bandcamp).*?\"" export_sd_4ed12435bcfe756bf51992a7.html | grep -oh "http.*[^\"]" > RayV_list
http://youtube.com/watch?v=KMRACkJGW1Y
http://youtube.com/watch?v=clibKrEDBhU
http://youtube.com/watch?v=ZiOI2y5007k
https://yuvalsaartheveryveryband.bandcamp.com/track/blackbird
http://youtube.com/watch?v=WXLM865u5bM
http://youtube.com/watch?v=-zAHs6wrz64
http://youtube.com/watch?v=kUvIdEWiQms
http://youtube.com/watch?v=Q5J0y-EbkII
@almog
almog / -
Created October 12, 2014 19:24
ydl-mp3 () {
youtube-dl -o "%(title)s.%(ext)s" --extract-audio --audio-format=mp3 $1
}

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.