Skip to content

Instantly share code, notes, and snippets.

@kfei
kfei / cpu-burn.sh
Created November 30, 2014 14:02
Burn CPU
# burn your 4 cores
for i in 1 2 3 4; do while : ; do : ; done & done
addrs bits pref mask
1 0 /32 255.255.255.255
2 1 /31 255.255.255.254
4 2 /30 255.255.255.252
8 3 /29 255.255.255.248
16 4 /28 255.255.255.240
32 5 /27 255.255.255.224
64 6 /26 255.255.255.192
128 7 /25 255.255.255.128
@kfei
kfei / fileio3.py
Created October 13, 2014 02:35
A Python3 ZMQ file transfer example
# File Transfer model #3
#
# In which the client requests each chunk individually, using
# command pipelining to give us a credit-based flow control.
import os
import sys
from threading import Thread
import zmq
import multiprocessing
def thread_func():
print "thread in"
while True:
pass
if __name__ == "__main__":
t1 = multiprocessing.Process(target = thread_func)
t1.start()
@kfei
kfei / Python: virsh-batch-start-vm.py
Last active August 29, 2015 14:02
Python: virsh-batch-start-vm
#!/usr/bin/env python
import sys
import threading
import Queue
import commands
import time
# thread class to run a command
import java.io.IOException;
import java.io.InputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
public class Exec {
def get_interface_name
interfaces = {}
puts 'Valid network interfaces detected are:'
interfaces_with_mac = `ifconfig -a | grep -i hwaddr | awk '{ if( match($1, /^eth/) ) {print $1, $5} }'`.lines.map(&:chomp)
interfaces_with_mac.each_with_index do |x, index|
interfaces[index] = x.split[0]
puts " #{index}) #{x.split[0]} ( #{x.split[1]} )"
end
print 'Please choose an interface to configure: '