Skip to content

Instantly share code, notes, and snippets.

@syed
syed / amazon_api_search.py
Created August 3, 2012 04:32
Gets data about books from amazon
from BeautifulSoup import BeautifulStoneSoup as bs
from quick_orm.core import Database
from sqlalchemy import Column,String,Text,Boolean
import bottlenose
import pprint
import logging
import re
import time
import xlrd
from collections import dqueue
class P(DistProcess):
def setup(ps, token_val):
ts = 0
process_set = ps
#requests: array of ts values, where requests[k] is ts of Pk's last request for token,
requests = { p : 0 for p in process_set}
requests[self] = 0
@syed
syed / tent_reminder.js
Created September 13, 2012 02:49
This is a simple on[x] script that I wrote to remind my friend to bring tent, sleeping bag and anti leech powder for our trek
// Initializing variables
var message = "Tent + Sleeping bag le kar aana aur agar aapke paas " +
"anti leech hai woh jo powder etc woh be le kar aana";
var contact = { name : "Dhiraj",phoneNumber : "+91123456789" } ;
var msg_time = new Date(2012,8,12,8,0,0,0); // Date(year, month, day, hours, minutes, seconds, milliseconds);
var msg_time_ms = msg_time.getTime();
// End of variables initializing
@syed
syed / tb_model.ipynb
Created July 9, 2013 18:26
Example use of pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@syed
syed / docker_io_limt.py
Created June 9, 2015 21:11
Simple python script to limit I/O bandwidth of a container
#!/bin/python
"""
This script uses cgroups to limit a docker container's read/write bandwidth
Usage:
limit_docker_io.py <container_id> --read=<read_bps> --write=<write_bps>
Options:
--read=<read_bps> Read bps 0 for unlimited [default: 0]
import requests
import sys
import json
import urllib
import graphitesend
from docopt import docopt
"""
Usage:
sfmetrics.py --sf_host=<sf_host> --sf_user=<sf_user> --sf_password=<sf_password> --graphite_host=<graphite_host> --interval=<interval>
@syed
syed / aes_cbc_pkcs5_b64.go
Last active December 12, 2022 10:11
This simple program is to demonstrate encryption and decryption in golang using AES CBC with PKCS5Padding
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
b64 "encoding/base64"
"errors"
"fmt"
"log"
@syed
syed / timing.py
Created June 7, 2016 17:48
Simple script which calculates time spent in a function. The function which is being timed should be decorated with @timing. Keeps track of stack, if children have an @timing, they are also included in the output
timing_indent = -1
call_graph = list()
def timing(f):
def wrap(*args, **kwargs):
global timing_indent
global call_graph
timing_indent += 1
#!/bin/bash
LOCAL_IP=$(hostname -i)
REMOTE_IP=$1
LOCAL_TUNNEL_IP=$2
REMOTE_TUNNEL_IP=$3
display_usage() {
echo -e "\nUsage: $0 [remote ip address] [local tunnel ip] [remote tunnel ip] \n"
}
yum install wget openssl-devel python-six python-sphinx gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel -y
useradd ovs
su - ovs
mkdir -p ~/rpmbuild/SOURCES
wget http://openvswitch.org/releases/openvswitch-2.9.2.tar.gz
cp openvswitch-2.9.2.tar.gz ~/rpmbuild/SOURCES/
tar xfz openvswitch-2.9.2.tar.gz