Skip to content

Instantly share code, notes, and snippets.

View daniyalzade's full-sized avatar

Eytan Daniyalzade daniyalzade

View GitHub Profile
Learn:
software transactional memory
couroutines
* http://www.dabeaz.com/coroutines/Coroutines.pdf
python 3
* Improvements to GIL
http://www.dabeaz.com/python/GIL.pdf
pypy
* Maybe getting rid of gil
* jit genarator
@daniyalzade
daniyalzade / gist:1271105
Created October 7, 2011 19:05
PyCodeConf Notes
Learn:
software transactional memory
couroutines
* http://www.dabeaz.com/coroutines/Coroutines.pdf
python 3
* Improvements to GIL
http://www.dabeaz.com/python/GIL.pdf
pypy
* Maybe getting rid of gil
* jit genarator
@daniyalzade
daniyalzade / connection.py
Created May 23, 2012 19:47
AutoReconnectingConnection
import functools
import logging
from pymongo.errors import AutoReconnect
from pymongo import Connection
from pymongo import ReplicaSetConnection
import time
import types
def wrap(func, num_retries, sleep_interval):
@functools.wraps(func)
function getDotted(data, field, def, delimeter) {
delimeter = delimeter || '.';
if (field.indexOf(delimeter) < 0) {
return data[field] || def;
}
var components = field.split(delimeter);
components = components.reverse();
while (!!components.length && (typeof(data) == 'object')) {
data = data[components.pop()]
}
@daniyalzade
daniyalzade / product_api.json
Created July 25, 2012 04:02
product_api.json
{
data: {
products: [
{
seo_title: "for_all_mankind_gwenevere_low-rise",
category_id: 237,
title: "7 for all mankind Gwenevere low-rise skinny jeans",
url: "http://www.net-a-porter.com/product/196792",
display_price: "$205",
price: "205",
@daniyalzade
daniyalzade / check_cluster.py
Created November 13, 2012 17:39
Nagios Plugin For Checking Uptime in a Cluster (over multiple hosts)
#!/usr/bin/env python
# Script to enure that the cluster defined by the hostgroup, or list
# hosts has enough healthy nodes as defined by the 'check_ping' plugin.
# If it has more than N number of unhealthy nodes, the plugin returns
# the appropriate error.
#
# To get the list of hosts from a hostgroup, this script parses nagios'
# hosts.cfg file which has the following format:
#
@daniyalzade
daniyalzade / adv_enumerate.py
Created November 18, 2012 23:12
Log progress while iterating over a list
import logging
def _display_msg(msg, use_print=False):
"""
@param msg: str
@param use_print: bool
"""
if use_print:
print msg
return
# MySQL get number of rows per table
select TABLE_NAME, TABLE_ROWS, DATA_LENGTH from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'db_name';
# Delete vim files
rm -rf ls -l **/.*.swp
# Find large ( 100MB > ) files
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
@daniyalzade
daniyalzade / getURLParameter.js
Created January 21, 2013 17:02
Get URL parameter in javascript
function getURLParameter(name) {
var val = (RegExp('[?|&]' + name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1];
return val ? decodeURI(val) : val;
}
@daniyalzade
daniyalzade / python_us_states.py
Created May 6, 2013 13:03
map of abbreviation to full name for all US states
states = {
'AK': 'Alaska',
'AL': 'Alabama',
'AR': 'Arkansas',
'AS': 'American Samoa',
'AZ': 'Arizona',
'CA': 'California',
'CO': 'Colorado',
'CT': 'Connecticut',
'DC': 'District of Columbia',