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
for file in *.html;do pandoc $file -f html -t plain -o ${file%.*}.md; done |
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
# Configure APT | |
sudo sed -i '%s/cn.archive.ubuntu.com/mirror.bit.edu.cn/g' /etc/apt/sources.list | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install build-essential | |
# Install VirtualBox addons | |
sudo mount -t auto /dev/cdrom /media/cdrom | |
cd /media/cdrom | |
sudo ./VBoxLinuxAdditions.run |
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
/* Bit Wtiddling Hacks http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | |
java.util.ArrayDeque - find the nearest power of two */ | |
private void allocateElements(int numElements) { | |
int initialCapacity = MIN_INITIAL_CAPACITY; | |
// Find the best power of two to hold elements. | |
// Tests "<=" because arrays aren't kept full. | |
if (numElements >= initialCapacity) { | |
initialCapacity = numElements; | |
initialCapacity |= (initialCapacity >>> 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
# build-essential in CentOS | |
sudo yum groupinstall 'Development Tools' |
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/bash | |
CONCURRENCY=8 | |
TIME_START=`date` | |
for ((idx = 0; idx < $CONCURRENCY; idx++)) | |
do | |
time echo "scale=5000; a(1)*4" | bc -l > /dev/null & | |
done | |
echo "$TIME_START Start" |
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
# Get Linode API python bindings from https://github.com/tjfontaine/linode-python | |
#!/usr/bin/python | |
from linode import api | |
instance = api.Api(key='abcdefg') | |
for domain in instance.domain_list(): | |
if domain['TYPE'] == 'master': | |
print "Updating %s (%i)..." % (domain['DOMAIN'], domain['DOMAINID']) |
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
# Create a temp big file on server | |
kymair:wwwroot/ $ dd if=/dev/zero of=file.zip bs=1M count=100 | |
# wget that file from client, two connections at the same time | |
➜ ~ wget kymair.com/file.zip > /dev/null 2&>1 & | |
[1] 79229 | |
➜ ~ wget kymair.com/file.zip > /dev/null 2&>1 & | |
[2] 79234 | |
# Client netstat result |
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 ruby | |
MAILBOXES = ['INBOX', 'Deleted Items'] | |
SERVER = 'server' | |
USERNAME = 'username' | |
PASSWORD = 'password' | |
require 'net/imap' | |
imap = Net::IMAP.new(SERVER) |
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
(use '[clojure.string :only [split]]) | |
(require '[clojure.java.io :as io]) | |
(def format-str "%1$-255s%2$09d%3$-255s%4$-1000s%5$-1s") | |
(defn format-line | |
[line] | |
(let [[v1 v2 v3 v4 v5] (split line #",")] | |
(format format-str v1 (read-string v2) v3 v4 v5))) |
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
(ns ldapper.core | |
(:require [clj-ldap.client :as ldap] | |
[clj-message-digest.core :as cdigest]) | |
(:gen-class)) | |
(def server (ldap/connect {:host "server:3997" :bind-dn "cn=Directory Manager" :password "password"})) | |
(def base-dn "ou=people,o=kymair.com") | |
(defn- hash-password |