Skip to content

Instantly share code, notes, and snippets.

View baxang's full-sized avatar

Sanghyun Park baxang

  • Jora
  • Sydney, Australia
View GitHub Profile
# A formtastic input which incorporates carrierwave uploader functionality.
#
# Intelligently adds the cache field, displays and links to the current
# value if there is one, adds a class to the wrapper when replacing an
# existing value, allows removing an existing value with the checkbox
# taking into account validation requirements.
#
# There are several options:
#
# * Toggle the replacement field with `replaceable: true/false`.
@baxang
baxang / rvm2rbenv.txt
Created May 16, 2012 12:50 — forked from brentertz/rvm2rbenv.txt
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@baxang
baxang / smi2srt.py
Created April 3, 2012 17:42
convert script in SMI to SRT format
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@package smi2srt
@brief this module is for convert .smi subtitle file into .srt subtitle
(Request by Alfred Chae)
Started : 2011/08/08
license: GPL
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@baxang
baxang / gist:1308662
Created October 24, 2011 09:27 — forked from dipolesource/gist:1265576
Log Juggernaut via Monit
check host juggernaut with address 127.0.0.1
start program = "/bin/bash -c '2>&1 1>>/home/deploy/juggernaut.log /usr/local/bin/node /usr/local/lib/node_modules/juggernaut/server.js'"
stop program = "/bin/kill -9 $(pidof node);/bin/kill -9 $(pgrep -f 'bash -c 2>&1 1>>/home/deploy/juggernaut.log')"
if failed port 8080 protocol HTTP
request /application.js
with timeout 10 seconds
then restart
@baxang
baxang / gist:1308661
Created October 24, 2011 09:27 — forked from Aslan/gist:536379
set daemon 30 # with start delay 30
set mailserver localhost # sudo apt-get install postfix
set mail-format { from: [email protected] }
set alert [email protected]
set logfile /var/log/monit.log
check process redis-server with pidfile /var/run/redis.pid
start program = "/usr/local/bin/redis-server /data/redis/redis.conf"
stop program = "/usr/bin/killall -9 redis-server"
if totalmem is greater than 500.0 MB for 5 cycles then alert
if cpu is greater than 80% for 5 cycles then alert
@baxang
baxang / dart.txt
Created September 19, 2011 06:33 — forked from paulmillr/dart.md
Google dart email
---------- Forwarded message ----------
From: Mark S. Miller <[email protected]>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: [email protected]
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.
@baxang
baxang / uploader_fu.rb
Created August 30, 2011 01:59 — forked from charly/uploader_fu.rb
a nice little module to help migrate from attachment_fu to carrierwave
# Helps you migrate from attachment_fu
# put it in your /lib dir and include it your xxxx_uploader.rb
module UploaderFu
def partition_dir
("%08d" % model.id).scan(/\d{4}/).join("/")
end
def model_dir
"#{model.class.to_s.underscore}/#{mounted_as}/"
ssh_user = "[email protected]" # for rsync deployment
remote_root = "~/path/to/remote/" # for rsync deployment
namespace :styles do
desc "Clear styles"
task :clear do
puts "*** Clearing styles ***"
system "rm -Rfv css/*"
end
desc "Generate styles"