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
// さらにKeyのメソッドにしてやれば、 | |
// KeyのことはKeyにやらせるというオブジェクト指向的な感じになる | |
Key.prototype.renderTo = function(cssId) { | |
if(this.notes!=null){ | |
for(var i=0; i < this.notes.length; i++){ | |
var selector = cssId + " ." + this.notes[i]; | |
$(selector).addClass("osu"); | |
} | |
} else { | |
this.notes=[]; |
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
// まずこうすれば関数はひとつにまとめられて | |
function renderNotes(key, cssId){//key1notesの中の状態を探って、それを#key1の鍵盤に反映させる関数 | |
if(key.notes!=null){ | |
for(var i=0;i<key1.notes.length;i++){ | |
var kari= cssId + " ." + key.notes[i]; | |
$(kari).addClass("osu"); | |
}//for文 | |
} else{ | |
key.notes=[]; | |
} |
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 | |
$arr1 = [1, 1, 0]; | |
$arr2 = [1, 0, 0]; | |
var_dump(array_map( | |
function($a, $b){ | |
if ($a == $b) { | |
return 1; | |
} else { | |
return 0; |
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
irb(main):005:0> article = Article.select(["articles.id as id", "categories.name as category_name"]).joins(:category)[0] | |
Article Load (0.3ms) SELECT articles.id as id, categories.name as category_name FROM "articles" INNER JOIN "categories" ON "categories"."id" = "articles"."category_id" | |
=> #<Article id: 6> | |
irb(main):006:0> article.id | |
=> 6 | |
irb(main):007:0> article.category_name | |
=> "live_info" |
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
var KeyBoard = function(){ | |
var keys = []; | |
for (var i = 0, l= 64; i < l; i++ ){ | |
keys[i] = false; | |
} | |
this.keys = keys; | |
}; | |
KeyBoard.prototype = { | |
indexOf: function(keyCode, oct){ |
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
module Nyan | |
class ConfigStore | |
class << self | |
attr_writer :setting_a, :setting_b, :setting_c | |
def setting_a | |
@setting_a || "default a" | |
end | |
def setting_b |
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 | |
$hash = array( | |
"a" => 1, | |
"b" => 2, | |
); | |
$jsonFormattedString = json_encode($hash); | |
?> | |
<html> | |
<head> |
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
jsonString = '{"a": 1, "b": 2}'; | |
json = JSON.parse(jsonString); | |
console.log(json["a"]); // 1 | |
console.log(json["b"]); // 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
<?php | |
$hash = array( | |
"a" => 1, | |
"b" => 2, | |
); | |
$jsonFormattedString = json_encode($hash); | |
echo $jsonFormattedString; // {"a":1,"b":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
var numberOf = { | |
"C": 0, | |
"C#/Db": 1, | |
"D": 2, | |
"D#/Eb": 3, | |
"E": 4, | |
"F": 5, | |
"F#/Gb": 6, | |
"G": 7, | |
"G#/Ab": 8, |