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
-----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.
<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']")
@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)
@almog
almog / selenium_cookies_to_mechanize_cookie_jar
Created July 12, 2014 17:12
Selenium cookies to Mechanize CookieJar
@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: