Skip to content

Instantly share code, notes, and snippets.

View ssut's full-sized avatar

Suhun Han ssut

View GitHub Profile
@ssut
ssut / skydrivedl.php
Last active December 16, 2015 05:09
SkyDrive direct download.. (Original: http://corpuscollectum.wordpress.com/2011/07/12/skydrive-direct-download-link-hotlink/, Procedure-Oriented)
<?php
ini_set('display_error', 1);
error_reporting(E_ALL & ~E_NOTICE);
class skyDriveDL {
// Location
private $loc;
// File
private $file;
@ssut
ssut / skydrivedl.rb
Last active December 17, 2015 13:29
Get SkyDrive direct download link with Ruby.
#encoding: UTF-8
class SkydriveGetter
attr_reader :fullLocation, :file
def initialize(id, file)
id = URI.decode(id) if id.include?('%')
@loc = id
@file = file
@ssut
ssut / lib.extension.php
Created June 5, 2013 13:26
Extension of PHP STL.
<?php
/**
* Library Extension :: Extension of PHP STL.
**/
function kDate($_addHyphen = false) {
return date($_addHyphen ? 'Y-m-d' : 'Ymd');
}
function kDatetime() {
@ssut
ssut / django-minify-middleware.py
Created September 5, 2013 22:57
Django html minify middleware.
#-*- coding: utf-8 -*-
import re
class MinifyMiddleware(object):
spaces = re.compile(r'^\s+', re.MULTILINE)
comments = re.compile(r'(\<!--\s*.*?((--\>)|$))', re.MULTILINE)
blank_attrs = re.compile(r'(\s\w+\=[\'|"]{2})', re.MULTILINE)
tag_types = re.compile(r'(\stype\=[\'|"]text\/\w+[\'|"])', re.MULTILINE)
def process_response(self, request, response):
@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)) {
@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 / 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 / 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 / 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 / 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"