Skip to content

Instantly share code, notes, and snippets.

@JohnKim
JohnKim / gist:5023190
Created February 24, 2013 09:08
Bijective
public class BijectiveUtils {
private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static final int BASE = 62;
public static String encode(int num) {
StringBuilder sb = new StringBuilder();
while ( num > 0 ) {
sb.append( ALPHABET.charAt( num % BASE ) );
@JohnKim
JohnKim / gist:5283550
Created April 1, 2013 06:54
scp (linux command)
# scp -r [folder] [user]@[IPAddress]:`pwd`
@JohnKim
JohnKim / GetPageTitleServlet.java
Last active December 15, 2015 15:49
get the Title from HTML page (for GAE)
package io.stalk.gae.html;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import javax.servlet.http.*;
@JohnKim
JohnKim / cmd-mcp.sh
Created April 2, 2013 00:53
여러대의 서버에 같은 쉘명령을 한번에 실행하기 (from http://www.powerbox.pe.kr/351)
### cmd.sh
#!/bin/sh
HOSTLIST=hostlist.dat
if [ ! -n "$1" ]
then
echo "usage: $0 \"command arg1 arg2 ... \""
exit 1
fi
for i in `cat ~/$HOSTLIST`
@JohnKim
JohnKim / new_gist_file
Created May 3, 2013 14:39
install nginx for OSX
# Install with brew
$ brew install nginx
# After install run:
$ sudo nginx
# Test it by going to URL: http://localhost:8080
# Configuration
@JohnKim
JohnKim / npush_dev_setting.txt
Last active December 31, 2015 12:08
init setting for Ubuntu (nPush Project)
# Login by root !!!!!!
# change root password
> passwd
# create npush user account
> adduser npush
> visudo
npush ALL=(ALL:ALL) ALL # add root privileges for npush user
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
# START:prefix
set -g prefix C-a
# END:prefix
# Free the original Ctrl-b prefix keybinding
# START:unbind
unbind C-b
# END:unbind
@JohnKim
JohnKim / install_grunt
Created December 29, 2013 05:21
install grunt and prepare xpush project.
npm install -g grunt-cli
npm install -g grunt-init
git clone https://github.com/gruntjs/grunt-init-jquery.git ~/.grunt-init/jquery
@JohnKim
JohnKim / CROS.js
Created January 13, 2014 23:25
CROS Sample
function makeRequest(method, url, params, fnLoad) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
// XDomainRequest for IE.
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
public class BijectiveUtils {
private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static final int BASE = 62;
public static String encode(int num) {
StringBuilder sb = new StringBuilder();
while ( num > 0 ) {
sb.append( ALPHABET.charAt( num % BASE ) );