Skip to content

Instantly share code, notes, and snippets.

View ssut's full-sized avatar

Suhun Han ssut

View GitHub Profile
@ssut
ssut / lib.rsa.php
Created May 7, 2014 02:30
RSA Encrypt & Decrypt library
<?php
/**
* RSA Encrypt & Decrypt library
*
* Original algorithm is orginated by Ron Rivest, Adi Shamir and Leonard Adleman.
* Produce PHP Code by Hx0A5F.
**/
class RSA {
private $publicKey = 0;
@ssut
ssut / packages.md
Last active November 27, 2016 10:37
memo
@ssut
ssut / payapp.py
Created May 17, 2016 12:53
A Simple PayApp Implementation
# coding: utf-8
try:
import requests
except ImportError:
raise ImportError(u'requests 패키지가 설치되어있지 않습니다.\n>> pip install requests')
from urllib.parse import parse_qsl
from collections import namedtuple
from datetime import datetime
import json
@ssut
ssut / main.py
Created February 9, 2016 07:06
Simplest way to sort Japanese in python
import icu
import romkan
from unihandecode import Unihandecoder
def main():
d = Unihandecoder(lang='ja')
collator = icu.Collator.createInstance(icu.Locale('ja_JP.UTF-8'))
table = [
u"女言葉の消失", # 2
@ssut
ssut / sidekiq
Created December 17, 2013 01:15
Starts and stops "sidekiq" message processor for padrino application. Requirement: rbenv, padrino, sidekiq and https://gist.github.com/passcod/3754086 /etc/init.d/sidekiq
#!/bin/sh
### BEGIN INIT INFO
## END INIT INFO
# You will need to modify these..
APP="app_name"
APP_DIR="/var/www/${APP}"
CONFIG_FILE="${APP_DIR}/config/sidekiq.yml"
REQUIRE="${APP_DIR}/config/workers.rb"
PID_FILE="${APP_DIR}/tmp/sidekiq.pid"
@ssut
ssut / douhao.js
Created November 17, 2013 09:26 — forked from darkfe/douhao.js
'3423112'.replace(/\d(?=(?:\d{3})+$)/g,'$&,')
"3,423,112"
'3423112'.replace(/(?!^)(?=(?:\d{3})+$)/g,',')
"3,423,112"
@ssut
ssut / qs.js
Created November 16, 2013 16:13
Query string access in javascript
function setGetParam() {
var url = arguments[2] || location.href;
if (arguments[0] instanceof Object) { // hash object
for(var arg in arguments[0]) {
if (!arg || !arguments[0][arg]) continue;
url = setGetParam(arg, arguments[0][arg], url);
}
} else if (typeof arguments[0] === 'string' && arguments[1]) {
paramName = arguments[0];
@ssut
ssut / findrepl.rb
Last active December 25, 2015 08:48
Simple ruby script: find string in multiple files and replace.
#!/usr/bin/env ruby
#
# First: Filename (*.html, *.rb, *.py and etc)
# Second: Find
# Third: Replacement
$pwd = Dir.pwd
$args = []
ARGV.each { |arg| $args.push(arg) }
if $args.size < 3
@ssut
ssut / Custom.css
Last active December 23, 2015 04:19 — forked from netj/Custom.css
/*
* 정확히 AppleGothic만 다른 글꼴로 바꾸는 사용자 스타일 시트
*
* 애플고딕을 쓰도록 명시적으로 지정한 사이트에서도 원하는 글꼴로 바꿀 수 있게 해주는 방법이며,
* 영문 글꼴이나 다른 한글 글꼴까지 몽땅 하나로 통일해서 써야 했던 font-family를 강제로 지정하는 방식과는 달리
* 정확히 애플고딕만 다른 글꼴로 바꿔서 사용하는 매우 깔끔한 방법입니다. :)
*
* 사용 방법:
* Safari는 아무 곳에나 저장해두고 환경설정 > 고급 > 스타일 시트에서 파일 선택
* Google Chrome은 ~/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css
@ssut
ssut / folder_scan.php
Created September 10, 2013 12:37
PHP Folder scan function.
<?php
function find_entry($dir, $orign_dir='') {
if(!is_dir($dir)) return null;
$d = dir($dir);
$result = "";
while($entry = $d->read()) {
if($entry != "." && $entry != "..") {
if(is_dir($dir . "/" . $entry)) {