- Copy
/etc/passwd /etc/group /etc/gshadow /etc/shadow /etc/hosts
from head to the newly installed node. - Sets
/etc/network/interfaces
with static IP address - apt-get install nfs-common
- Sets
/etc/fstab
to mount home to the head node. - Reboot.
This file contains 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/sh | |
TIMESTAMP=`date +"%F"` | |
SRC_PATH="/base/src/path" | |
TAR_PATH="/target/path" | |
if [ ! -d $TAR_PATH ]; then | |
mkdir -p $TAR_PATH | |
fi |
This file contains 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
class Trace: | |
"""A trace iterator | |
For each run of iteration, this object returns one trace entry | |
""" | |
def __init__(self, filepath): | |
self.filepath = filepath | |
self.fd = open(filepath) | |
def __enter__(self): | |
return self |
This file contains 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
pid_t getppid_for_process(pid_t pid) { | |
#if defined(__APPLE__) | |
struct kinfo_proc info; | |
size_t length = sizeof(struct kinfo_proc); | |
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; | |
if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) | |
return -1; | |
if (length == 0) | |
return -1; | |
return info.kp_eproc.e_ppid; |
This file contains 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
#!/usr/bin/env python | |
# | |
# Lei Xu <eddyxu@gmail.com> | |
"""Manually set CPU cores online or offline | |
""" | |
import glob | |
import optparse | |
import os |
This file contains 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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 2K bytes over 1 Gbps network 20,000 ns | |
Read 1 MB sequentially from memory 250,000 ns | |
Round trip within same datacenter 500,000 ns | |
Disk seek 10,000,000 ns |
This file contains 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
class benchmark(object): | |
"""Run a function as benchmark for several times. | |
Usage: | |
>>> @benchmark(times=1) # times is a optional parameter. | |
>>> def awesome_benchmark(arg1, arg2): | |
>>> # do awesome benchmarks. | |
""" | |
def __init__(self, **kwargs): | |
self.times = kwargs.get('times', 1) |
This file contains 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/sh | |
# | |
# Git Precommit Script for Research project. | |
# Lei Xu <eddyxu@gmail.com> | |
# Enforce C++ Style Checking (Google C++ Style). | |
# Note: you must have cpplint.py installed in your $PATH | |
CPPFILES=`git diff --cached --name-only | grep -E '^.+\.(h|hpp|cpp|cc)$'` | |
if [ ! -z "$CPPFILES" ]; then | |
echo "$CPPFILES" | xargs -n 128 cpplint.py |
This file contains 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
f1 = 1 | |
f2 = 1 | |
while True: | |
f2, f1 = f1 + f2, f2 |
This file contains 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
#!/usr/bin/env python | |
# | |
# Author: Lei Xu <eddyxu@gmail.com> | |
"""Eular Project Problem 119 | |
http://projecteuler.net/problem=119 | |
""" | |
import heapq |
OlderNewer