Skip to content

Instantly share code, notes, and snippets.

# http://www.spoj.com/problems/TEST/
guess = STDIN.gets.chomp().to_i
while guess != 42
puts guess
guess = STDIN.gets.chomp().to_i
end
@jin
jin / osrc.rb
Last active August 29, 2015 14:01
require 'json'
require 'net/http'
require 'rubygems'
staffs = %w(weesun knmnyn wgx731 Leventhan franklingu Limy Muhammad-Muneer)
baseurl = "http://osrc.dfm.io/"
# Construct the json URLs
def construct_urls(base_url, usernames, suffix)
urls = Array.new
@jin
jin / Q1.js
Last active December 22, 2015 13:59
DG3
// integration using Simpson's Law
function calc_integral (func, a, b, n) {
var h = (b - a) / n;
function helper (func, acc, k) {
if (k === n) {
if (k % 2 === 0) {
return (acc + 2 * func(a + k * h));
} else {
return (acc + 4 * func(a + k * h));
@jin
jin / git-restore-deleted-file.sh
Created October 2, 2011 13:24
Git: Restore a deleted file
#!/bin/sh
git log --diff-filter=D --summary
git checkout $commit~1 filename
array = [
{:name=>"site a", :url=>"http://example.org/site/1/"},
{:name=>"site b", :url=>"http://example.org/site/2/"},
{:name=>"site c", :url=>"http://example.org/site/3/"},
{:name=>"site d", :url=>"http://example.org/site/1/"},
{:name=>"site e", :url=>"http://example.org/site/2/"},
{:name=>"site f", :url=>"http://example.org/site/6/"},
{:name=>"site g", :url=>"http://example.org/site/1/"}
]
@jin
jin / ex37.rb
Created September 13, 2011 08:16
Ruby symbols review: Learn Ruby The Hard Way
descriptions = {}
# ========
# KEYWORDS
# ========
# -----
# alias
# -----
@jin
jin / rails-3.1-gemfile.rb
Created September 2, 2011 01:46
Gemfile of fresh Rails 3.1 app, clean RVM 1.9.2 gemset except for Rails itself
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@jin
jin / about.md
Last active September 11, 2019 16:52 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer