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 / 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
@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 / 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 / gist:2894997
Created June 8, 2012 11:02
๋ฏธํˆฌ ๋ฏธํ‹ฐ์ฑ„ํŒ… ๋ถ๋งˆํด๋ฆฟ
javascript:window.open("<๋ฏธ๋‹ˆ์ฑ„ํŒ… ์ฃผ์†Œ>", "", "width=300,height=400,toolbar=0,menubar=0,scrollbars=1");
@codian
codian / gist:2633214
Created May 8, 2012 07:07
Common API Response Layout
/*
๊ณต์šฉ API ์‘๋‹ต ํ˜•์‹
-----------------
* metadata๋ฅผ ์œ„ํ•œ ๋ณ„๋„ ํ•„๋“œ๋Š” ์ •ํ•˜์ง€ ์•Š์Œ
* result๋Š” ๋ฐ˜๋“œ์‹œ ํ•ด์‹œ
* 'status' ๊ฐ€ ์—๋Ÿฌ์ธ ๊ฒฝ์šฐ ๋” ์ž์„ธํ•œ ์—๋Ÿฌ ์ •๋ณด๋Š” 'result' ํ•„๋“œ์— ์ง€์ •
*/
@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: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 / 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: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