Skip to content

Instantly share code, notes, and snippets.

From 1d94e295d4514f2a509d3b608b515e08e04d4577 Mon Sep 17 00:00:00 2001
From: Leo Ju <mr.simple@gmail.com>
Date: Sun, 16 Aug 2009 21:00:21 +0900
Subject: [PATCH] Added format string %r to show subversion revision
---
src/vcprompt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/vcprompt.c b/src/vcprompt.c
@simple
simple / gist:967656
Created May 11, 2011 23:52
update Ubuntu package sources (for Korean users)
sudo vim -e /etc/apt/sources.list <<EOF
%s/kr.archive.ubuntu.com/ftp.daum.net/g
w
q
EOF
sudo apt-get update
(1..100).each do |num|
claps = 0
num.to_s.each_char { |c| claps += 1 if /[369]/.match(c) }
word = claps > 0 ? 'clap! ' * claps : num
print "#{word},"
end
@simple
simple / gist:1153147
Created August 18, 2011 02:18
AES sample code
public class AesTest {
@Test
public void stringCanBeEncripted() throws NoSuchAlgorithmException, NoSuchProviderException,
NoSuchPaddingException, InvalidKeyException, ShortBufferException, IllegalBlockSizeException, BadPaddingException {
String original = "Kiwiple Inc.";
AesToy aes = new AesToy();
String encrypted = aes.encrypt(original);
System.out.println("encrypted: " + encrypted);
String decrypted = aes.decrypt(encrypted);
@simple
simple / AesCrypto.java
Created August 18, 2011 03:37
AES Sample (simpler)
// modified version of http://www.androidsnippets.com/encryptdecrypt-strings
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class AesCrypto {
private static String secret = "Sulley#@Wazowski$%";
@simple
simple / gist:1156308
Created August 19, 2011 08:12
Count Characters
#!/usr/bin/env ruby
def serialize_types(types, ratios)
serialized = ""
types.each_with_index do | type, i |
occurrences = (ratios[i] * 100).to_i
serialized += type * occurrences
end
serialized
end
@simple
simple / simplify_apache_log.rb
Created August 24, 2011 08:51
Preprocessing Apache Log
#!/usr/bin/env ruby
require 'date'
require 'apachelogregex'
# apache log format
parser = ApacheLogRegex.new('%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %I %b %D')
File.open(ARGV[0]).readlines.each do | line |
p = parser.parse(line)
@simple
simple / gist:1286928
Created October 14, 2011 12:13
shell command to run java class
# in a eclipse project's bin directory
java -cp .:`for jar in ../lib/*; do echo -n $jar:; done` com.leoju.clitoy.MainHandler
@simple
simple / haproxy.init
Created October 22, 2011 09:30
SysV init script for HAProxy
#!/bin/sh
#
# haproxy tcp/http proxy daemon
#
# chkconfig: <default runlevel(s)> <start> <stop>
# description: tcp/http proxy daemon, installed for ESG server proxy
#
### BEGIN INIT INFO
# Provides:
@simple
simple / gist:1364716
Created November 14, 2011 18:43 — forked from kwilczynski/gist:1170467
Upstart configutation file for MongoDB with NUMA support
# Ubuntu upstart file at /etc/init/mongodb.conf
limit nofile 32768 32768
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
pre-start script
mkdir -p /data/mongodb &> /dev/null
mkdir -p /data/logs/mongo &> /dev/null
chown mongodb:nogroup /data/mongodb &> /dev/null