Skip to content

Instantly share code, notes, and snippets.

View ubershmekel's full-sized avatar
🤙
What's a github status?

Yuval Greenfield ubershmekel

🤙
What's a github status?
View GitHub Profile
@ubershmekel
ubershmekel / gist:7c38943afccc58382e4a
Created July 11, 2014 21:30
Kombu unacked messages were missing when calling .get()
"""
Kombu and Celery were doing something strange were I noticed rabbit had
a large number of unacked messages, but when I hit .get() I got nothing.
This manifested on the client side of things at times where it would work once,
hang the next. And then work again.
"""
# This was the bad code
with kombu.Connection(RABBIT_HOST) as conn:
@ubershmekel
ubershmekel / youtube_viewcount_filter.js
Created July 21, 2014 02:51
Filter a youtube channel by viewcounts
var thresh = 100e6;
var lis = document.querySelectorAll('.yt-lockup-meta-info li');
for(var i = 0; i < lis.length; i++) {
var text = lis[i].textContent;
if(text.indexOf('views') == -1) {
continue;
}
if(Number(text.replace(' views','').replace(/,/g, '')) < thresh) {
//console.log('-' + text);
var li = lis[i].parentNode.parentNode.parentNode.parentNode.parentNode;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" lang="de" content="Zeitleiste, Zeitlinie, Zeitkarte, Geschichte, Chronologie">
<meta name="keywords" lang="en" content="Timeline, Timemap, History, Chronology">
<title>Timeline - Proof-of-concept</title>
<!-- That's my local d3 path. When working locally, use your local path. -->
@ubershmekel
ubershmekel / debug_http_requests.py
Created August 30, 2015 16:37
This will cause the requests module to print out anything it's doing
"""
Thank you
http://stackoverflow.com/a/24588289/177498
"""
def debug():
import logging
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
import sys
import pprint
import json
import requests
base_url = 'http://localhost:9200'
INDEX_COUNT = 400
@ubershmekel
ubershmekel / distribute_and_pip.py
Created December 14, 2012 16:04 — forked from anonymous/gist:4286446
One-click pip setup for windows
"""
This gist is a one-click pip setup for windows:
1. installs distribute if needed
2. installs pip
3. (On windows) sets the path environment variable so "pip" is always runnable from cmd.
Tested on Windows 7 with python2.7
"""
@ubershmekel
ubershmekel / generic_repr.py
Created October 27, 2015 17:32
Simple repr methods that allow you to reconstruct a simple object
"""
These two repr implementations make a "repr" that you can just drop into your class if it's a simple one.
"""
class A:
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return "%s(**%r)" % (self.__class__.__name__, self.__dict__)
@ubershmekel
ubershmekel / startup_times.py
Last active December 10, 2015 05:48
Test startup times for python2.7 vs python3.3
#!/usr/bin/python2.7
"""
Outputs on my PC:
"python2.7 startup_times.py nop" min run 0.019732 seconds
"python3.3 startup_times.py nop" min run 0.026251 seconds
"""
import subprocess
import time
@ubershmekel
ubershmekel / h1b.py
Created January 27, 2013 20:43
h1b wages analysis
"""
Analyze USA h1b salaries
data from http://www.foreignlaborcert.doleta.gov/quarterlydata.cfm
specifically:
http://www.foreignlaborcert.doleta.gov/pdf/quarter_2_2012/PW_FY2012_Q2.csv
"""
import math
@ubershmekel
ubershmekel / shapeTrig.html
Created February 20, 2013 08:01
A d3js animation of sine and cosine with different base shapes.
<!DOCTYPE html>
<html manifest="main.appcache">
<meta charset="utf-8">
<style>
.circle, .wave {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}