This file contains 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 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 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 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 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
require 'spec_helper' | |
describe "EmailValidator" do | |
before do | |
@validator = EmailValidator.new({:attributes => {email: ''}}) | |
@mock = double("Foo") | |
allow(@mock).to receive(:errors).and_return([]) | |
allow(@mock.errors).to receive(:[]).and_return({}) | |
allow(@mock.errors[]).to receive(:<<) |
This file contains 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
set nocompatible | |
filetype off | |
set rtp+=~/.vim/vundle.git/ | |
call vundle#rc() | |
Bundle 'quickrun.vim' | |
Bundle 'neocomplcache' |
This file contains 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 | |
require_once('simpletest/autorun.php'); | |
require_once('Calc.php'); | |
class TestOfCalc extends UnitTestCase { | |
function testCalcAdd() { | |
$calc = new Calc(); | |
// 1 + 1 = 2 | |
$this->assertEqual($calc->add(1,1), 2); |
This file contains 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
require 'rake' | |
require 'rspec/core/rake_task' | |
# RSpec::Core::RakeTask.new(:spec) | |
# task :default => :spec | |
task :default do | |
filelist = FileList['spec/*_spec.rb'].join(' ') | |
sh "bundle exec rspec #{filelist}" | |
end |
This file contains 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 | |
define('FOO', 1); | |
define('BAR', 2); | |
// 変数展開が「{$」で始まっている場合、関数の実行等が可能です。 | |
$c = 'constant'; | |
echo "FOO: {constant('FOO')}, BAR: {constant('BAR')}" . PHP_EOL; // => FOO: 1, BAR: 2 |
This file contains 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
<script> | |
var Obj = function(){ | |
var background = "#fff"; | |
var state = "on"; | |
this.change_state = function(){ | |
if(state === "on"){ | |
state = "off"; | |
background = "#000"; | |
} else { | |
state = "on"; |
OlderNewer