Skip to content

Instantly share code, notes, and snippets.

View wagurano's full-sized avatar
🍈

dallos wagurano

🍈
View GitHub Profile
@wagurano
wagurano / ruby3x3.md
Last active December 11, 2015 16:46
미리 만나는 루비 3

Ruby3x3

저자

@wagurano 줄여서 와그, 루비니언, 평화를 사랑하며 코딩하는 프로그래머

시작하며

서울 펄 몽거스의 펄 크리스마스 달력을 참고하여 루비 크리스마스 달력(Advent Calendar)에 참여하는 글입니다.

지난 9월말쯤 트위터에 마츠모토 유키히로(이하 마츠)씨가 루비 3.0에 대해 발표하였습니다. 그리고 얼마전 11월 루비 컨퍼런스에서 Ruby3 challenges 라는 제목으로 루비 2.3.0과 루비3.0에 대해 소개하였습니다. 여기서는 11월 컨퍼런스 동영상, 모두발언 및 질의응답을 토대로 일부 재구성하여 요약 전달해드리겠습니다.

@wagurano
wagurano / how-to-netsted-form.md
Last active November 15, 2015 15:10
Nested form rails

입력 폼 중첩

설문조사 사례로 살펴보는 모델 관계에 따라 중첩하는 입력 폼

준비

설문조사 서식으로 입력폼을 만듭니다.

rails new surveyform

@wagurano
wagurano / general-index.html.erb
Last active November 3, 2015 10:59
form-example
<h1>Test</h1>
<%= form_tag { 'basic form tag' } %>
<%= form_tag('/posts') { 'form posts'} %>
<%= form_tag('/posts/1', method: :put) { 'form posts/1'} %>
<%= form_tag('/upload', multipart: true) { 'form upload' } %>
<%= form_tag('/posts') do -%>
<div><%= submit_tag 'Save' %></div>
<% end -%>
<%= form_tag('/posts', remote: true) { 'remote' } %>
<%= form_tag('http://far.away.com/form', authenticity_token: false) { 'token false' } %>
@wagurano
wagurano / jpgmv.rb
Created August 29, 2015 05:50
Move all of contents files to images directory
require 'FileUtils'
Dir["contents/**/*"].select{ |f| File.file? f }.map{ |f| FileUtils.move "#{f}", "images/#{File.basename f}.jpg" }
require 'minitest/autorun'
begin
require_relative 'hamming'
rescue LoadError => e
puts "\n\n#{e.backtrace.first} #{e.message}"
puts DATA.read
exit 1
end
class HammingTest < Minitest::Test
@wagurano
wagurano / 1thingbar.js
Last active August 29, 2015 14:17
1thing.kr 배너 담기
var OneThingBar=function() {
// 1thing.kr - Let's start with one thing.
var styl = document.createElement('style')
styl.innerHTML = "div#notification-banner { background: rgba(255, 51, 0, 1); border-radius: 0 0 6px 6px; color: rgba(255, 255, 255, 1); cursor: pointer; font-weight: bold; font-family: Open Sans; left: 0%; line-height: 25px; margin-left: 0px; position: fixed; text-align: center; top: 0; width: 100%; } div#notification-banner span { padding: 3px 10px; }"
document.body.appendChild(styl)
var banner = document.createElement("div")
banner.id = "notification-banner"
banner.onclick = (function () { return function() {this.style.display='none'} })()
banner.title="누르면 사라집니다.(click to hide)"
banner.innerHTML = '뭐라도 해야겠는데 그저 막막하신가요? 작은 것 하나를 <a href="http://1thing.kr/" target=_blank>시작</a>해봐요.'
@wagurano
wagurano / add_star_to_name.rb
Created February 12, 2015 09:45
가게이름 일부 가리는 방법
name = [
"상회",
"분당상가",
"백화점",
"NC백화점"
]
print "name = "
p name
@wagurano
wagurano / getpharm.egen.rb
Last active September 25, 2015 13:21
당번약국을 보여주고 당번인데 문닫은 약국을 신고합니다. 구글드라이브 [CSV파일](https://drive.google.com/file/d/0B8WezMmea38UVjlxc3FHR3V1Q28/view?usp=sharing) 2014년 10월 기준, 심사평가원 + 중앙응급의료원 대한약사회에서 휴일지킴이약국을 http://www.pharm114.or.kr/ 운영합니다. 여기서는 중앙응급의료원 http://www.e-gen.or.kr/ 에서 자료를 가져옵니다. 공공데이타포털에서도 자료를 가져올 수 있는데 하루 1000 회 제한이 있습니다. 심사평가원의 데이타를 추정해보면 약 20만 여개로 추정하는데 공공API로는 수일내…
#encoding: utf-8
require 'net/http'
require 'nokogiri'
require 'open-uri'
require 'timeout'
require 'json'
TIMEOUT_CNT = 42
def egen_print_pharm_info code
class Place
include Mongoid::Document
include Mongoid::Timestamps
include Geocoder::Model::Mongoid
field :type
field :category
field :category_desc
field :name
field :description