Skip to content

Instantly share code, notes, and snippets.

Avatar

ChangHoon, Jung seapy

View GitHub Profile
View README.md

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.

@seapy
seapy / td-agent.conf
Last active Aug 29, 2015
/etc/td-agent/td-agent.conf 예제(apache to elasticsearch)
View td-agent.conf
###################################
## Input
<source>
type tail
format /^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<timestamp>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" (?<response_time_micro_sec>[^ ]*))?$/
path /home/ubuntu/log_maker/tmp/log.access
pos_file /var/log/td-agent/apache.access.pos
tag apache.access
</source>
@seapy
seapy / .screenrc
Last active Dec 19, 2015
내 서버들에서 사용할 screen 설정. coursera 의 "Startup Engineering" 에 나왔던 예제를 수정. 원래 예제에서는 emacs 사용을 위해 단축키를 많이 바꿔치기 했었음 ex 1) 서버에 git이 설치되어 있지 않은경우. https 대신 http 사용 curl -o .screenrc http://gist.github.com/seapy/xxxx/xxxx/.screenrc ex2) 서버에 git이 설치되어 있는 경우 git clone https://gist.github.com/5955083.git dotfiles ln -s dotfiles/.screenrc .screenrc
View .screenrc
# GNU Screen configuration file
# seapy <iamseapy@gmail.com>
#
# Notes
# -----
# 1. To change the colors of the hardstatus line, change this line:
# sorendition "+b +kG"
# Example: blue (+b) highlight with black text (k) on a green background (G)
# Example: sorendition "+r +kG" is red highlighting with black text on a green background
#
@seapy
seapy / jquery.ui.js
Last active Dec 18, 2015
jQuery UI 에서 제공하는 DatePicker 를 사용할때 ie 10 미만 버전에서는 기본적으로는 잘 작동하지만 페이지가 스크롤되는경우 스크롤된 상태에서 DatePicker 를 표시할때 잘못된 위치가 나오는 경우가 있다. 이는 DatePicker 의 문제만은 아니고 jQuery UI 전체적인 문제인것 같다. 이게 일괄적으로 적용하면 ie10 에서 잘못된 위치에 나오기 때문에 브라우저 버전 체크가 필요하다.
View jquery.ui.js
_showDatepicker: function(input) {
input = input.target || input;
if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
input = $("input", input.parentNode)[0];
}
.......... 생략
if (!$.datepicker._pos) { // position below input
$.datepicker._pos = $.datepicker._findPos(input);
$.datepicker._pos[1] += input.offsetHeight; // add the height
// patch start
@seapy
seapy / gist:5509333
Last active Dec 16, 2015
내가 Mac 에서 사용하는 ".profile" 설정
View gist:5509333
# 터미널 색 설정
export TERM="xterm-color"
export CLICOLOR=1
export LSCOLORS="gxfxcxdxbxegedabagacad"
# Alias 설정
alias ll="ls -al"
# 마우스 오른쪽으로 다른프로그램 열기할때 중복으로 앱이 나오는거 제거하는 방법
alias fixow='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"'
@seapy
seapy / post.rb
Created Apr 27, 2013
for Rails ActiveRecord Callbacks order check
View post.rb
class Post < ActiveRecord::Base
belongs_to :user
attr_accessible :body, :title
after_destroy :after_destroy
private
def after_destroy
puts "Post after_destroy"
end
@seapy
seapy / gist:2979190
Created Jun 23, 2012
Wordpress(MySQL) To Rails Blog(PostgreSQL) Migration Rake task edit
View gist:2979190
# encoding: UTF-8
require 'php_serialize'
# MySQL 접속 정보를 가지는 ActiveRecord 클래스 생성
class SeapyBlog < ActiveRecord::Base
end
# 기존 MySQL DB 접속 정보 설정
SeapyBlog.establish_connection(
:adapter => "mysql2",