Skip to content

Instantly share code, notes, and snippets.

// Simulates PHP's date function
Date.prototype.format = function(format) {
var returnStr = '';
var replace = Date.replaceChars;
for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
returnStr += curChar;
}
else if (replace[curChar]) {
returnStr += replace[curChar].call(this);
} else if (curChar != "\\"){
@mytory
mytory / mytory-bind-tab-navigation.js
Last active December 21, 2015 10:29
easy bind tab navigation.
/**
* ex)
* bind_tab_navigation({
* target: ".family-site__a",
* prev: '.brand-page-last',
* prev_pre_event: function(){
* $('.brand-page-content').show();
* },
* next: '.family-site-first',
* next_pre_event: function(){
@mytory
mytory / gist:6238053
Created August 15, 2013 03:33
my .bash_profile
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\n\[\e[0m\]$ '
export PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH"
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
export EDITOR=nano
PATH=$PATH:/usr/local/mysql/bin
alias ls='gls --color=auto -F'
source .git-completion.bash
@mytory
mytory / iconv.php
Last active December 20, 2015 21:39
Convert file encoding with `//IGNORE` flag. This script convert a file, can`t convert files. usage: php iconv.php from-encoding to-encoding filename
<?php
// filename : iconv.php
if($argc != 4){
echo "invalid arg!\nsyntax) php {$argv[0]} from to filename\nex) php {$argv[0]} euc-kr utf-8 /path/to/filename\n";
exit(0);
}
$from = $argv[1];
$to = $argv[2];
$filename = $argv[3];
/**
초성 중성 종성 분리 하기
유니코드 한글은 0xAC00 으로부터
초성 19개, 중상21개, 종성28개로 이루어지고
이들을 조합한 11,172개의 문자를 갖는다.
한글코드의 값 = ((초성 * 21) + 중성) * 28 + 종성 + 0xAC00
(0xAC00은 'ㄱ'의 코드값)
/**
초성 중성 종성 분리 하기
유니코드 한글은 0xAC00 으로부터
초성 19개, 중상21개, 종성28개로 이루어지고
이들을 조합한 11,172개의 문자를 갖는다.
한글코드의 값 = ((초성 * 21) + 중성) * 28 + 종성 + 0xAC00
(0xAC00은 'ㄱ'의 코드값)