Skip to content

Instantly share code, notes, and snippets.

View ChangJoo-Park's full-sized avatar
:octocat:
๐ŸŒฑ

ChangJoo Park(๋ฐ•์ฐฝ์ฃผ) ChangJoo-Park

:octocat:
๐ŸŒฑ
View GitHub Profile
@ChangJoo-Park
ChangJoo-Park / seoulweather_wundergorund.html
Created November 23, 2012 05:11
์„œ์šธ์‹œ ๋‚ ์”จ ์ •๋ณด ์˜ˆ์ œ
<!DOCTYPE html>
<html>
<head>
<title>์„œ์šธ์‹œ ๋‚ ์”จ์ •๋ณด-wunderground API์ด์šฉ</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
@ChangJoo-Park
ChangJoo-Park / analyzer.rb
Last active December 10, 2015 03:28
oliver.txtํŒŒ์ผ์„ ์ฝ์–ด ํŒŒ์ผ์˜ ๋‚ด์šฉ์„ ๋ถ„์„ํ•œ๋‹ค. ์ „์ฒด ๊ธธ์ด, ๊ธ€์ž์ˆ˜(๊ณต๋ฐฑ ์œ ๋ฌด), ๋‹จ์–ด, ๋ฌธ์žฅ, ๋ฌธ๋‹จ์˜ ์ˆ˜๋ฅผ ๋ถ„์„
# encoding: utf-8
lines=File.readlines("oliver.txt")
line_count=lines.size
text=lines.join
total_character=text.length
total_character_no_whitespace=text.gsub(/\s+/,'').length
word_count=text.split.length
paragraph_count=text.split(/\n\n/).length
sentence_count=text.split(/\.|\!|\?/).length
puts "์ „์ฒด ๊ธธ์ด : #{line_count}"
@ChangJoo-Park
ChangJoo-Park / stop_wods.rb
Last active December 10, 2015 03:28
๋ถˆ์šฉ์–ด๋ฅผ ์ œ์™ธํ•˜๊ณ  ๋ณด์—ฌ์คŒ
# encoding: utf-8
# Stop_words 2012-12-26
stop_words = %w{the a by on for of are with just but and to the my I has some in}
text=%q{Korea is officially the only divided nation in the world.}
words = text.scan(/\w+/)
key_words = words.select { |word| !stop_words.include?(word)}
puts "๋ฌธ์žฅ ์ค‘ ํ‚ค์›Œ๋“œ์˜ ๋น„์œจ์€ : #{((key_words.length.to_f/words.length.to_f)*100).to_i}%"
puts key_words.join(' ')
@ChangJoo-Park
ChangJoo-Park / current_user.rb
Created January 14, 2013 17:58
||= ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋™์ผํ•œ ๋‚ด์šฉ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ๋‹ค์‹œ ์ฟผ๋ฆฌ๋ฅผ ํ•˜์ง€ ์•Š์Œ
def current_user
@current_user ||= User.find(session[:user_id])
end
@ChangJoo-Park
ChangJoo-Park / TaskController.rb
Created January 14, 2013 18:12
find๋ฅผ find_by_all ๋กœ ๋ฐ”๊พธ๋ฉด ๋” ๊ฐ„๋‹จํ•˜๋‹ค
class TaskController < ApplicationController
def incomplete
@tasks = Task.find(:all, :conditions => ['complete = ?', false])
end
def last_incomplete
@task = Task.find(:first, :conditions => ['complete =?', false], :order => 'created_at DESC')
end
end
@ChangJoo-Park
ChangJoo-Park / helloworld.rb
Created April 10, 2013 14:26
Ruby Hello World!
=begin ๋ฌธ์ž์—ด ์ถœ๋ ฅํ•ด๋ณด๊ธฐ
**์ด ๋ฌธ์„œ๋Š” ๋ฃจ๋น„ 2.0.0-p0 ๋ฒ„์ „์˜ Ruby core API ๊ธฐ๋ฐ˜์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.**
** ์ž‘์„ฑ์ž ์ •๋ณด
** ๋ฐ•์ฐฝ์ฃผ
** [email protected]
** http://parkcj.wordpress.com
** 2013-04-07
single quotation vs double quotation
''์™€ ""์˜ ์ฐจ์ด๋ฅผ ์•Œ์•„๋ณด์ž
์šฐ์„  puts ๋Š” ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ด๋‹ค.
@ChangJoo-Park
ChangJoo-Park / use_number.rb
Created April 10, 2013 14:45
๋ฃจ๋น„์—์„œ ๋ฌธ์ž์—ด ์•ˆ์—์„œ ์ฝ”๋“œ๋ฅผ ์ถœ๋ ฅํ•˜์—ฌ ๋ด…๋‹ˆ๋‹ค.
=begin
**์ด ๋ฌธ์„œ๋Š” ๋ฃจ๋น„ 2.0.0-p0 ๋ฒ„์ „์˜ Ruby core API ๊ธฐ๋ฐ˜์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.**
** ์ž‘์„ฑ์ž ์ •๋ณด
** ๋ฐ•์ฐฝ์ฃผ
** [email protected]
** http://parkcj.wordpress.com
** 2013-04-07
์˜ˆ๋ฅผ ๋“ค์–ด ํŠน์ • ํšŸ์ˆ˜๋งŒํผ ๋ฌธ์žฅ์„ ๋ฐ˜๋ณตํ•  ์ผ์ด ์ƒ๊ธด๋‹ค๋ฉด
์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?
-> 1. 1๋ฒˆ์˜ Hello World!๋ฅผ ์ถœ๋ ฅํ•ด๋ณด์ž
@ChangJoo-Park
ChangJoo-Park / for_end.rb
Created April 10, 2013 14:45
for ~in ๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ ์˜ค๊ฐ๋„ ์ œ 1ํ˜ธ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
=begin
**์ด ๋ฌธ์„œ๋Š” ๋ฃจ๋น„ 2.0.0-p0 ๋ฒ„์ „์˜ Ruby core API ๊ธฐ๋ฐ˜์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.**
** ์ž‘์„ฑ์ž ์ •๋ณด
** ๋ฐ•์ฐฝ์ฃผ
** [email protected]
** http://parkcj.wordpress.com
** 2013-04-07
์ด์ƒ ์‹œ์ธ์˜ ์‹œ ์˜ค๊ฐ๋„ ์ œ 1ํ˜ธ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ๋ณด์ž
์‹œ์˜ ์ „๋ฌธ :
์˜ค๊ฐ๋„(็ƒ็žฐๅœ–) ์‹œ ์ œ1ํ˜ธ
@ChangJoo-Park
ChangJoo-Park / more_string.rb
Created April 17, 2013 13:35
String Class์˜ ์‚ฌ์šฉ๋ฒ•์„ ์•Œ์•„๋ด…๋‹ˆ๋‹ค. http://ruby-doc.org/core-1.9.3/String.html
# encoding: utf-8
=begin
**์ด ๋ฌธ์„œ๋Š” ๋ฃจ๋น„ 1.9.3-p392 ๋ฒ„์ „์˜ Ruby core API ๊ธฐ๋ฐ˜์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.**
** ์ž‘์„ฑ์ž ์ •๋ณด
** ๋ฐ•์ฐฝ์ฃผ
** [email protected]
** http://parkcj.wordpress.com
** 2013-04-07
์กฐ๊ธˆ ๋” ๋ฌธ์ž์—ด์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž.
@ChangJoo-Park
ChangJoo-Park / input_output_num.rb
Last active December 16, 2015 08:18
์ˆซ์ž๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ for ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
# encoding: utf-8
=begin
**์ด ๋ฌธ์„œ๋Š” ๋ฃจ๋น„ 2.0.0-p0 ๋ฒ„์ „์˜ Ruby core API ๊ธฐ๋ฐ˜์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.**
** ์ž‘์„ฑ์ž ์ •๋ณด
** ๋ฐ•์ฐฝ์ฃผ
** [email protected]
** http://parkcj.wordpress.com
** 2013-04-07
์ด์ƒ์˜ ์˜ค๊ฐ๋„ ์ œ 1ํ˜ธ ๊ณ„์†