This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reads netids from stdin and prints email addresses to stdout | |
# see http://ldap3.readthedocs.io/tutorial_searches.html | |
# and https://www.it.northwestern.edu/bin/docs/CentralAuthenticationServicesThroughLDAP.pdf | |
# | |
# prereq: pip install ldap3 | |
# usage: echo [email protected] | python netid_lookup.py | |
from ldap3 import Server, Connection, ALL, ALL_ATTRIBUTES | |
import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "types.h" | |
#include "stat.h" | |
#include "user.h" | |
void run(void* id) { | |
printf(1, "hello\n"); | |
volatile int i; | |
for(i=0; i<100000000; i++); | |
printf(1, "Child %d done\n", *(int*)id); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
static volatile char* person1; | |
static volatile char* person2; | |
static const int LOOPS = 1e4; | |
void* mythread(void* arg) { | |
printf("%s: begin\n", (char*)arg); | |
int i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
static volatile int counter = 0; | |
static const int LOOPS = 1e7; | |
void* mythread(void* arg) { | |
printf("%s: begin\n", (char*)arg); | |
int i; | |
for (i=0; i<LOOPS; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sends a TCP DNS request in two packets. | |
# First sends the message size, then sends the message. | |
# This behavior is similar to that of the Windows nslookup command. | |
import socket, binascii, sys, struct | |
def main(dns_server): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
# disable Nagle's algorithm, to allow request to be sent in two pieces. | |
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) | |
s.connect((dns_server, 53)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Converts all ogg files in the current path to mp3 files. | |
# This is useful for moving a music libary to iTunes, which doesn't support ogg | |
find .|grep 'ogg$' > /tmp/ogg_files.txt | |
while read line; do | |
basepath=$(echo $line | sed 's/.ogg$//g') | |
echo $basepath | |
# get as much id3 tag information as possible from the path | |
trackAndSong=$(basename "$basepath") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Parallelization functions | |
# Maximum number of processes to run in parallel. | |
# A good value for this is one fewer than the number of cores available | |
NP=14 | |
# wait until fewer jobs are running than number of processors | |
function queue { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Implements GNU seq functionality. | |
# Useful on IBM AIX systems which don't have GNU coreutils. | |
if [ -z "$3" ]; then | |
# if no third arg | |
incr=1 | |
j=$2 | |
else | |
incr=$2 |