Skip to content

Instantly share code, notes, and snippets.

View tcnksm's full-sized avatar
☺️
Yo

Taichi Nakashima tcnksm

☺️
Yo
View GitHub Profile
@tcnksm
tcnksm / sum_hash_values.rb
Created October 31, 2013 03:19
The sum of hash values by proc
hash = {a: 23, b: 24, c: 25}
puts hash.values.inject(&:+) == (23+24+25) # >> true
@tcnksm
tcnksm / chnage_table_name.rb
Created October 31, 2013 10:48
Change DB table name by ActiveRecord::Migration
class ChangeTableName < ActiveRecord::Migration
def self.up
rename_table :a_tables, :b_tables
end
def self.down
rename_table :b_tables, :a_tables
end
end
@tcnksm
tcnksm / add_index.rb
Created October 31, 2013 10:51
Add index by ActiveRecord::Migration
class Addindex < ActiveRecord::Migration
def self.up
add_index :a_table, :name
end
end
@tcnksm
tcnksm / create_table.rb
Created October 31, 2013 12:26
Create DB table by ActiveRecord::Migration
class CreateTable < ActiveRecord::Migration
def self.up
create_table :a_tables do |t|
t.column :name1, :integer, :null => false
t.column :name2, :text, :null => false
t.timestamps
end
end
def self.down
@tcnksm
tcnksm / index.html
Last active December 27, 2015 05:59
Responsive Vimeo container (e.g. iframe for Vimeo ) by scss
<div class="video-container">
<iframe src="http://player.vimeo.com/video/78074896" width="500" height="281" frameborder="0"></iframe>
</div>
@tcnksm
tcnksm / layout.scss
Created November 2, 2013 11:50
Responsive centered single column page by scss
body {
font-size: 18px;
margin 0 auto;
@media screen and (max-width: 1040px){
font-size: 16px;
width: 60%;
}
@media screen and (max-width: 600px){
@tcnksm
tcnksm / parse_json.go
Created November 3, 2013 09:32
Parse .json file by Go
package main
import (
"encoding/json"
"fmt"
"strings"
)
const blob = `[
{"Title":"0redev", "URL": "http//oredev.org"},
@tcnksm
tcnksm / flag.go
Created November 3, 2013 09:44
Parse command line argument by Go
package main
import (
"flag"
"fmt"
"time"
)
var (
message = flag.String("message", "Hello!", "What to say")
@tcnksm
tcnksm / install_sqlplus.md
Last active February 4, 2022 12:43
How to install oracle client to Ubuntu 12.04

Install SQL*Plus

  1. Download .rpm package here
    • oracle-instantclinet*-basic-*.rpm
    • oracle-instantclinet*-devel-*.rpm
    • oracle-instantclinet*-sqlplus-*.rpm
  2. Install alien (sudo apt-get install alien)
  3. Convert the rpm files and install
    • sudo alien -i oracle-instantclinet*-basic-*.rpm
  • sudo alien -i oracle-instantclinet*-devel-*.rpm
@tcnksm
tcnksm / args.rb
Created November 11, 2013 06:02
Variable length arguments in Ruby
def function(*args)
puts args.join(",")
end
function("a","b","c")
# >> a,b,c