Skip to content

Instantly share code, notes, and snippets.

Avatar

CHANN channprj

View GitHub Profile
@channprj
channprj / ghost-booting-forever
Last active Jan 31, 2016
Ghost blog booting script with forever package.
View ghost-booting-forever
#!/bin/sh
### BEGIN INIT INFO
# Provides: blog
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
@channprj
channprj / daemon
Created Mar 3, 2016
Init script for service on RPI2
View daemon
#!/bin/sh
### BEGIN INIT INFO
# Provides: my_service
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Put a short description of the service here
# Description: Put a long description of the service here
View jupyter
#!/bin/sh
### BEGIN INIT INFO
# Provides: kupy
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Jupyter init script
# Description: Jupyter init script
View coupang.py
# coupang cash code
# https://coupang.saramin.co.kr/_service/coupang/apply_site/apply/recruit_default.asp
# shift operation (x >> 1) and convert to ascii character
cipher_text = ['212', '242', '214', '194', '220', '206', '128', '198', '222', '234', '224', '194', '220', '206', '92', '198', '222', '218']
def shift_operation(x):
x = int(x)
return x >> 1
for i in range(len(cipher_text)):
@channprj
channprj / nginx.conf
Created Aug 25, 2016 — forked from timmyomahony/nginx.conf
Python, UWSGI, Supervisor & Nginx
View nginx.conf
upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;
View bugs_music_player_black_theme.js
// ==UserScript==
// @name Bugs Music Player Black
// @namespace https://chann.kr
// @version 0.1
// @description bugs music player black theme by default
// @author CHANN
// @match http*://music.bugs.co.kr/newPlayer?*
// @grant none
// ==/UserScript==
@channprj
channprj / nginx.conf
Created Oct 11, 2016
Nginx configuration for Docker on Windows.
View nginx.conf
### docker run -it -p 12300:80 -p 12301:8000 -p 12302:8888 -d your/docker-image:latest zsh
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@channprj
channprj / run_cronjob_solo.sh
Last active Nov 2, 2016
Preventing duplicate shell script executions
View run_cronjob_solo.sh
#!/bin/sh
# WIP prevent duplicate cron job shell executions.
# refer: http://bencane.com/2015/09/22/preventing-duplicate-cron-job-executions/
do_function() {
# do something...
}
PIDFILE=/path/to/<YOUR_PID_FILE>.pid
if [ -f $PIDFILE ] ## if pid file exist and it is not a directory
@channprj
channprj / set.js
Last active Mar 8, 2017
Simple and naive implementation of array without duplicated items; Python set-like data structure written in JS. #help #wanted
View set.js
var jsSet = { item: 0 }; // use Object key as set item
item = 'setItem'
if (!(item in jsSet)) { // if item not in jsSet
jsSet[item] = 1; // save item with meaningless value
}
sessionStorage.setItem('jsSet', JSON.stringify(Object.keys(usages))) // save into sessionStorage
@channprj
channprj / cntAllsessionStorageValues.js
Last active Mar 8, 2017
Count all of sessionStorage values.
View cntAllsessionStorageValues.js
var cnt = 0;
for(var i=0; i < sessionStorage.length; i++){
if (JSON.parse(sessionStorage.getItem(sessionStorage.key(i))).length > 0) {
cnt = cnt + JSON.parse(sessionStorage.getItem(sessionStorage.key(i))).length;
}
}