This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Object.create(): the New Way to Create Objects in JavaScript | |
* http://www.htmlgoodies.com/beyond/javascript/object.create-the-new-way-to-create-objects-in-javascript.html | |
*/ | |
var Car2 = Object.create(null); //this is an empty object, like {} | |
Car2.prototype = { | |
getInfo: function() { | |
return 'A ' + this.color + ' ' + this.desc + '.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WordList | |
class << self | |
def find(option = {}) | |
default_option = {limit: 10}.merge(option) | |
option = default_option.merge(option) | |
word_list_path = Rails.root.join('lib/word_list/config/') | |
@word_list = [] | |
@file ||= YAML.load_file(word_list_path.to_s + file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 外部の認証機構よりcallbackしたときにCSRFのチェックにひっかかってしまう問題への対処法 | |
skip_before_filter :verify_authenticity_token, only: [ :callback ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* static修飾子を使うとあたかもインスタンスのメンバ変数のような振る舞いができる | |
*/ | |
class Hoge | |
{ | |
static $hoge = null; | |
function add() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE class_A SET sex_code =1; | |
SELECT * FROM class_A; | |
UPDATE class_A SET sex_code = 2 WHERE id IN (3,4); | |
-- sex_codeをわかりやすく出力する | |
SELECT name, | |
CASE sex_code | |
WHEN 1 THEN 'Male' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ascii = [] | |
0x61.upto(0x7a){|a| ascii.push(a.chr) } | |
0.upto(9) {|num| ascii.push(num.to_s) } | |
list = [] | |
ascii.each do |chr1| | |
ascii.each do |chr2| | |
ascii.each do |chr3| | |
list.push(chr1 + chr2 + chr3) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class PascalsTriangle | |
@@count= 10 | |
@@list = [] | |
def create(list) | |
sum = [] | |
i = 1 | |
while i < list.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while true; do | |
read -p "Do you wish to install this program? [y/n]" yn | |
case $yn in | |
[Yy] ) echo "Install!"; break;; | |
[Nn] ) exit;; | |
* ) echo "Please answer y or n.";; | |
esac | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 単純挿入法で配列の値を昇順にソートする | |
*/ | |
var list = [8, 1, 3, 4, 9, 5], | |
i = 1, | |
j, | |
tmp; | |
for (i; i < list.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
# | |
# 単純挿入法で配列の値を昇順にソートする | |
# | |
list = [8, 1, 3, 4, 9, 5] | |
i = 1 | |
while i < list.size do | |
j = i |