Skip to content

Instantly share code, notes, and snippets.

View jschaub30's full-sized avatar

Jeremy Schaub jschaub30

View GitHub Profile
@jschaub30
jschaub30 / set_cpu_freq.sh
Created August 27, 2015 19:40
shell script to set cpu frequency to max on power machines
#!/bin/bash
echo Setting CPU to performance
for c in $(seq 0 8 192)
do
sudo cpufreq-set -c $c -r -g performance
done
@jschaub30
jschaub30 / gist:ce65fc9f62ac1ab2bc50
Created April 8, 2015 20:00
Python script to split columns from csv file
#!/usr/bin/python
# Input: CSV file with headers, column names
# x,y,z
# 1,2,3
# 4,5,6
# Output: CSV file
# Usage:
# ./split-columns.py [IN_CSV] [COLUMN NAMES]
# Example: ./split-columns.py in.csv x z
import sys
@jschaub30
jschaub30 / gist:4f347c2be2145cc84157
Created April 8, 2015 19:15
R script to split columns from csv file
#!/usr/bin/Rscript
# Input: CSV file with headers
# x,y,z
# 1,2,3
# 4,5,6
# Output: CSV file
# Usage:
# ./split-columns.R [IN_CSV] [COLUMN NAMES]
# Example: ./split-columns.R in.csv x z
@jschaub30
jschaub30 / gist:ab44ce1be4d93a2603d1
Created April 29, 2015 15:07
Bash script to process file line by line
#!/bin/bash
# Input = CSV file with timestamp as 3rd field
# 1,2,Wed Apr 29 09:46:58 CDT 2015
# 3,4,Wed Apr 29 09:46:58 CDT 2015
# Converts timestamp to linux time
while read line
do
A=$(echo $line | cut -d, -f1-2)
D=$(echo $line | cut -d, -f3)
@jschaub30
jschaub30 / gen-random-graph.py
Created May 4, 2015 17:53
Python script to generate random edge list of graph based on nodes and edges
#!/usr/bin/python
import sys
import random
def main(argList):
if '-edges' in argList:
a = argList.index('-edges')
edges = int(argList[a+1])
@jschaub30
jschaub30 / gist:8d13e24422cccee13b6d
Last active August 29, 2015 14:21
R recursive function to write hierarchical data frame to json file with childen
# http://stackoverflow.com/questions/12818864/how-to-write-to-json-with-children-from-r
# example input
# year month size
# 2007 1 100
# ...
# 2007 12 850
# 2008 1 432
# ...
makeList <- function(x){
@jschaub30
jschaub30 / read_interrupts.sh
Created June 15, 2015 16:05
Bash script to read network interrupts in Ubuntu linux
#!/bin/bash
[[ $# -lt 1 ]] && echo Usage: $0 INTERFACE && exit 1
IFACE=$1
cat /proc/interrupts | grep "$IFACE-" | cut -d':' -f1 > tmp.interfaces
echo Reading affinity of $IFACE
for IRQ in $(cat tmp.interfaces)
@jschaub30
jschaub30 / set_interrupts.sh
Created June 15, 2015 16:15
Bash script to set network interrupts in Ubuntu linux
#!/bin/bash
[[ $# -lt 1 ]] && echo "Usage: $0 [INTERFACE] [RESET]" && exit 1
IFACE=$1
# Tweak the CPUSTART to fit your system
CPUSTART=32
[[ $IFACE == "eth2" ]] && CPUSTART=8
[[ $IFACE == "eth3" ]] && CPUSTART=16
[[ $IFACE == "eth4" ]] && CPUSTART=24
@jschaub30
jschaub30 / measure_io.sh
Last active August 29, 2015 14:23
Bash script to test sequential IO (read and write) and read IOPS using ioping utility
#!/bin/bash
# Test sequential IO (read and write) and read IOPS
# Creates CSV and HTML output
# Usegu: ./measure_io.sh [DIRECTORY]
CWD=$1
[ $# -lt 1 ] && CWD=$(pwd)
ioping -h 2> tmpfile
[ $? -ne 0 ] && echo ioping not found--"sudo apt-get install ioping" or download here: https://code.google.com/p/ioping/ && exit 1
rm tmpfile
@jschaub30
jschaub30 / mention.py
Created July 13, 2015 16:26
python script using requests and BeautifulSoup
#!/usr/bin/python
'''
Read wordpress post and parse out handle and email
Uses requests and BeautifulSoup
'''
import requests
from bs4 import BeautifulSoup
r = requests.get('http://arlab093.austin.ibm.com/blog/?p=2742')