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 / decision_tree_code_gen.py
Created November 27, 2012 13:35
Generate python code from orange-canvas decision trees
"""
How to use:
1. Place a "Python Script" node on your canvas
2. Hook your "Classification Tree" node out into the "Python Script" input
3. Paste this gist in the python script and hit "Execute"
The output should be similar to this:
# slope (<32.000, 34.000>)
if slope <=1.008: return False #(<7.000, 0.000>)
@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 / remove_rows.py
Last active March 14, 2018 00:48
Remove certain rows from orange-canvas data with a python node
import Orange
bad_list = [
'abc',
'bcd',
]
id_index = in_data.domain.index('the_col_id')
out_data = Orange.data.Table(in_data)
# reversed so that the indexing is consistent after deletion
for i, row in reversed(list(enumerate(in_data))):
@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;
}
@ubershmekel
ubershmekel / censor_ascii.py
Created May 26, 2013 16:50
Censor out ascii art, made for Candy Box
import pprint
import os
from collections import Counter
ascii_markers = "|\\/_\" ()n"
def ascii_prob(line):
line = line.strip()
@ubershmekel
ubershmekel / SimpleHTTPServerSSL.py
Created August 9, 2013 15:28
SimpleHTTPServerSSL.py is a python 3 version of SimpleSecureHTTPServer.py from code.activestate.com
'''
SimpleHTTPServerSSL.py - simple HTTP server supporting SSL/TLS. I.e. HTTPS. For python 3.3
- replace CERT and KEY with the location of your .pem server file.
- the default port is 443.
usage: python SimpleHTTPServerSSL.py
based on http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
'''
@ubershmekel
ubershmekel / json_history_to_kml.py
Last active July 4, 2023 10:08
Convert LocationHistory.json from Google takeout of location history (latitude) to a usable KML file for viewing in Google Earth.
"""
Convert LocationHistory.json from Google takeout of location history (latitude)
to a usable KML file for viewing in Google Earth.
Usage:
python json_history_to_kml.py LocationHistory.json
"""
Data from
http://en.wikipedia.org/wiki/CPU_socket#List_of_80x86_sockets_and_slots
copy pasted html to excel, copy pasted excel to python
ran python
pasted output to excel, drew a graph
There's probably a simpler way to do a pivot table but I don't know how.