Skip to content

Instantly share code, notes, and snippets.

View ssut's full-sized avatar

Suhun Han ssut

View GitHub Profile
#!/bin/bash
NAME=$1
FROM=$2
PIDFILE=".$1.pid"
DIR=$(pwd)
PERIOD=${3:-7}
PRIORITY=${4:-10}
FILENAME="$(date +%Y-%m-%d_%H%M).tar.gz"
BACKUPDIR="$DIR/backups/$NAME"
@ssut
ssut / Code.gs
Last active August 29, 2015 14:06
get exchange rate from wooribank
function getDate(decrease) {
var date = new Date();
if(decrease && decrease > 0) {
date = new Date(date);
date.setDate(date.getDate() - decrease);
}
var yyyy = date.getFullYear().toString(),
dd = date.getDate().toString(),
mm = (date.getMonth() + 1).toString();
@ssut
ssut / raggedness.py
Last active August 29, 2015 14:04
very weird raggedness word-wrap implementation written in Python
# -*- coding: utf-8 -*-
from sys import argv, exit
cac = []
res = []
words = []
M = 0
for x in range(1000):
cac.append([-1 for j in range(1000)])
@ssut
ssut / attachment.php
Last active August 2, 2019 09:07 — forked from kijin/attachment.php
UTF-8 file download function, support remote file passing(proxy) with http range header
<?php
/**
* PHP File download function.
* Version 1.4
*
* Copyright (c) 2014 성기진 Kijin Sung
* Modified by ssut
*
* License: MIT License (a.k.a. X11 License)
@ssut
ssut / check_pep8.py
Last active August 29, 2015 14:02
python pep8 style guide checker -- http://legacy.python.org/dev/peps/pep-0008/
#!/usr/bin/env python
import os
import sys
import pep8
class Writer:
def __init__(self, exclude=[], stdout=None):
self.content = []
self.exclude = exclude
@ssut
ssut / river_status.py
Created June 5, 2014 14:43
Get South Korea river status from koreawqi.go.kr
#-*- coding: utf-8 -*-
import contextlib
import re
import urllib
from bs4 import BeautifulSoup
from datetime import datetime
from textwrap import dedent as trim
now = lambda: datetime.now().strftime("%Y%m%d%H")
@ssut
ssut / benchmark.py
Last active August 24, 2019 08:54
Python decorator endpoint implementation (like Flask blueprint module) - O(1)
#-*- coding: utf-8 -*-
import time
from collections import namedtuple
from test import ep as app
BenchResult = namedtuple('BenchResult', ['str', 'time'])
def benchmark(str, times=100000):
t_start = time.time()
for i in range(times):
@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 / puma.rb
Created April 22, 2014 16:07
puma on_worker_boot
on_worker_boot do
request_thread_count = Puma.cli_config.options[:max_threads]
Sidekiq.configure_client do |cfg|
cfg.redis = ConnectionPool.new(:size => 10, :timeout => 3) { Redis.connect }
end
cmdline = `cat /proc/#{$$}/cmdline`
# compress assets
# reference: app.rb - L:97
if Puma.cli_config.options[:environment] == 'production' and cmdline.include? 'worker 0'
@ssut
ssut / benchmark.rb
Created April 15, 2014 13:57
Ruby Object Serialization Performance Test (Native vs OJ Library)
require 'benchmark'
require 'oj'
require 'json'
require 'ostruct'
N_OJ = 500_000
ex_HASH = { 'one' => 1, 'array' => [ true, false ] }
ex_JSON = '{ "one": 1, "array": [ true, false ] }'