Skip to content

Instantly share code, notes, and snippets.

View dictcp's full-sized avatar

Dick Tang dictcp

View GitHub Profile
/*
* linux 2.6.37-3.x.x x86_64, ~100 LOC
* gcc-4.6 -O2 semtex.c && ./a.out
* 2010 sd@fucksheep.org, salut!
*
* update may 2013:
* seems like centos 2.6.32 backported the perf bug, lol.
* jewgold to 115T6jzGrVMgQ2Nt1Wnua7Ch1EuL9WXT2g if you insist.
*/
@dictcp
dictcp / gist:6079944
Last active December 20, 2015 05:39
Install Ruby 2, Rail 4 on Ubuntu 12.04 LTS
#install required packages
apt-get update
apt-get upgrade -y
apt-get install -y git curl build-essential libssl-dev libcurl4-openssl-dev nodejs
#optional
apt-get install libsqlite3-dev sqlite3
@dictcp
dictcp / stop_firefox.pl
Created March 2, 2014 09:30
send SIGSTOP to firefox when the workstation is locked, in order to save the CPU power
#!/usr/bin/perl
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'\"";
open (IN, "$cmd |");
while (<IN>) {
if (m/^\s+boolean true/) {
print "*** Screensaver is active ***\n";
system("killall -s SIGSTOP firefox plugin-container");
#!/bin/bash
#
# template script for generating CentOS container for LXC
#
#
# lxc: linux Container library
# Authors:
Vagrant.configure("2") do |config|
config.vm.box = "debian-wheezy72-x64-vbox43"
config.vm.box_url = "http://box.puphpet.com/debian-wheezy72-x64-vbox43.box"
config.vm.network "private_network", ip: "192.168.56.101"
config.vm.synced_folder "./", "/var/www", id: "vagrant-root", :nfs => false
config.vm.usable_port_range = (2200..2250)
@dictcp
dictcp / kernel_pep_install.sh
Last active August 29, 2015 14:13
my kernel build with uksm+BFQ patches for Ubuntu 14.04/14.10
echo "deb [trusted=yes] https://apt.fury.io/dictcp/ /" | sudo tee /etc/apt/sources.list.d/dictcp.list
sudo apt-get update && sudo apt-get install linux-image-3.16.0-28-pep
@dictcp
dictcp / 20-noto-cjk.conf
Created May 3, 2015 06:56
update 20-noto-cjk.conf for new Noto-CJK font naming
<fontconfig>
<match target="pattern">
<test name="lang">
<string>zh-tw</string>
</test>
<test name="family">
<string>sans-serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans CJK TC</string>
@dictcp
dictcp / create-simple-dynomite-cluster.sh
Last active August 29, 2015 14:21
Tasting Dynomite (dynamo implementation for redis) in 1 minute
#!/bin/bash
# assuming we are on Ubuntu 14.04 with docker proper installed
apt-get install -y build-essential dh-autoreconf git libssl-dev libtool
git clone https://github.com/Netflix/dynomite
cd dynomite
git checkout v0.4.0
autoreconf -fvi
./configure
#!/bin/sh
# The bandwidth to simulate, here about 56kilobit per second. This is layer 2 bandwidth, so TCP/UDP and IP overhead will apply
BW="56kbps"
# _Half_ the latency that we aim for. Since this applies to both the WAN port and Wi-Fi, the delay is applied twice, so this actually puts it at around 120+ms
LATENCY="60ms"
# Chance of packet loss. Also applied to both interfaces, so it is 1%.
LOSS="0.5%"
# The device name of your wifi device.
WIFI="wlan0"
#!/bin/bash
# enable root login & password login
sed -i 's/^[# ]*PermitRootLogin$/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^[# ]*PasswordAuthentication$/PasswordAuthentication yes/' /etc/ssh/sshd_config
/etc/init.d/ssh restart > /dev/null
/etc/init.d/sshd restart > /dev/null
echo '-----------------------------------------'
if [ "`cat /etc/shadow | grep root | cut -d: -f2`" == '!*' ]; then