Skip to content

Instantly share code, notes, and snippets.

@comfuture
comfuture / manage-daemon
Created November 11, 2010 06:28
init script sample for gunicorn daemonized flask app
#!/bin/bash
gunicorn="/usr/local/bin/gunicorn"
prog="dev.maroo.info"
PROJECT_HOME="/home/maroo/sites/$prog"
pid="/var/lock/$prog"
RETVAL=0
start() {
@comfuture
comfuture / backup.sh
Created July 29, 2011 06:04
safe minecraft incremental backup script
#!/bin/sh
# init git repository with "git init" command
# minecraft server is running on screen named "mc"
# ^M means newline character. type c-V-M in your editor
# put this file in your minecraft server's directory
# edit crontab with "crontab -e" and add this line:
# 0 12 * * * /path/to/minecraft/backup.sh > /dev/null 2>&1
CWD=$(readlink -f `dirname $0`)
screen -S mc -X stuff "say [Backup] Server goes readonly in 10 seconds^M"
@comfuture
comfuture / kakao.ipynb
Created September 29, 2017 02:53
카카오 공채 문제풀이
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@comfuture
comfuture / backup.sh
Created February 9, 2011 08:46
backup daily to remote host, and delete old backups smarter
#!/bin/bash
date=`date "+%Y-%m-%dT%H_%M_%S"`
HOME=/YOUR/LOCALHOME
SERVER=ID@HOST
DIR=backup
rsync -azP \
--bwlimit=500 \
--delete \
--delete-excluded \
@comfuture
comfuture / DBStorageStream.php
Created May 23, 2011 06:14
using database as filesystem
<?php
class DBStorageStream
{
const DDL = <<<EOF
CREATE TABLE IF NOT EXISTS `table_dbfs` (
`path` VARCHAR(255) NOT NULL PRIMARY KEY,
`data` LONGTEXT,
`is_dir` CHAR(1) NOT NULL DEFAULT 'N',
`created_at` DATETIME,
const jar = {}
function canonical(path) {
// remove trailing slash
if (path[path.length - 1] === '/') {
path = path.substring(0, path.length - 1)
}
return path
}
def xxrange(start, stop, step=1):
cur = start
while cur < stop:
yield cur
cur += step
locs = reversed([(lat, lng) for lat in xxrange(18.0, 64.0, 0.1) \
for lng in xxrange(-124.0, -66.0, 0.1) if lat is not lng])
for i, loc in enumerate(locs):
@comfuture
comfuture / sms
Last active September 13, 2017 01:19
#!/usr/bin/osascript
on run argv
set nr to item 1 of argv
set msg to item 2 of argv
tell application "System Events"
tell application "Messages" to activate
end tell
tell application "Messages"
from threading import Thread
try:
import gevent
except ImportError:
pass
def async(fn):
def decorator(*args, **kwargs):
# if use_greenlet:
gevent.spawn(fn, *args, **kwargs)
PING ec2-52-79-42-106.ap-northeast-2.compute.amazonaws.com (52.79.42.106): 56 data bytes
64 bytes from 52.79.42.106: icmp_seq=0 ttl=47 time=15.730 ms
64 bytes from 52.79.42.106: icmp_seq=1 ttl=47 time=10.836 ms
64 bytes from 52.79.42.106: icmp_seq=2 ttl=47 time=10.514 ms
64 bytes from 52.79.42.106: icmp_seq=3 ttl=47 time=12.312 ms
^C
--- ec2-52-79-42-106.ap-northeast-2.compute.amazonaws.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 10.514/12.348/15.730/2.067 ms
comfuture:~ comfuture$ traceroute ec2-52-79-42-106.ap-northeast-2.compute.amazonaws.com