Skip to content

Instantly share code, notes, and snippets.

View codian's full-sized avatar

codian codian

  • Watcha
  • South Korea
View GitHub Profile
@codian
codian / las.py
Last active August 29, 2015 14:17
Look and Say
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
import re
r = re.compile('((\d)\\2*)')
s = '1'
print s
for _ in range(50):
s = ''.join([''.join([str(len(m[0])), m[0][0]]) for m in r.findall(s)])
print s
@codian
codian / gist:1369486
Created November 16, 2011 07:06
alias_method_chain quiz
class Original
def hello
puts "Original"
end
end
module FeatureA
def self.included(base)
base.class_eval do
alias_method_chain :hello, :feature_a
@codian
codian / key-bindings.json
Created February 11, 2012 04:58
sublime text 2 설정
[
{ "keys": ["super+ctrl+left"], "command": "next_view_in_stack" },
{ "keys": ["super+ctrl+right"], "command": "prev_view_in_stack" }
]
@codian
codian / gist:2069206
Created March 18, 2012 05:36
current git branch name on prompt
export PS1="\[\033[34m\]\w\[\033[35m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.split(/\n/).grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1)')\"\`\[\033[00m\]> "
@codian
codian / gist:2158145
Created March 22, 2012 12:55
PhantomJS로 현재 TV 편성표 이미지로 떨구기
page = new WebPage()
url = 'http://search.naver.com/search.naver?where=nexearch&query=tv%ED%8E%B8%EC%84%B1%ED%91%9C&x=0&y=0&sm=top_sug.pre&fbm=0&acr=1&acq=TV&qdt=0&ie=utf8'
page.open url, (status) ->
if (status != "success")
console.log "invalid response: #{status}"
phantom.exit()
page.clipRect = { top: 340, left: 180, width: 590, height: 400 }
page.render('tv.png')
@codian
codian / gist:2633214
Created May 8, 2012 07:07
Common API Response Layout
/*
공용 API 응답 형식
-----------------
* metadata를 위한 별도 필드는 정하지 않음
* result는 반드시 해시
* 'status' 가 에러인 경우 더 자세한 에러 정보는 'result' 필드에 지정
*/
@codian
codian / gist:2894997
Created June 8, 2012 11:02
미투 미티채팅 북마클릿
javascript:window.open("<미니채팅 주소>", "", "width=300,height=400,toolbar=0,menubar=0,scrollbars=1");
@codian
codian / default.css
Created July 29, 2012 03:12
사파리 6에서 기본 폰트를 설정을 위한 User CSS
/*
사파리 6에서 기본 폰트 설정이 없어짐. 대신 Preferences > Advanced > Style sheet 옵션을
통해 CSS를 지정하여 기본 폰트를 지정할 수 있음. 다음은 기본 폰트를 다음 나눔고딕(OTF)로 지정하고
입반적으로 사용되는 폰트명에 대해 alias 설정 한다.
*/
/* 기본 폰트를 나눔고딕으로 지정 */
body { font-family: NanumGothicOTF; }
/* Font alias 설정 */
@codian
codian / bookmarklet.js
Created July 30, 2012 03:04
clean-me2day-wiki bookmarklet
// 아래 코드를 복사해 북마크에 등록하세요
// 북마크의 제목은 적당히 정하시고 아래 코드는 주소 부분에 붙여 넣으시기 바랍니다.
javascript:(function() {var d=document;var s=d.createElement('script');s.setAttribute('src','https://raw.github.com/gist/3203853/clean-me2day-wiki.js');d.getElementsByTagName('head')[0].appendChild(s);})()
@codian
codian / coffee_sale.rb
Last active October 13, 2015 19:18
아일러브커피-원하는 만큼의 원두 사용을 위해 판매해야 하는 메뉴 조합은?
class Bean
MENUS = [25, 50, 99, 210, 310, 170, 270, 590, 430, 620, 360, 450,
420, 320, 677, 308, 210, 536, 364, 466, 675, 572, 820, 959, 861,
1060, 1200, 260, 483].sort
attr_accessor :remain, :menus
def initialize(num)
if num.is_a?(Bean)
@remain = num.remain