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 Nyan | |
self.instance_eval do | |
def nyan | |
p 'nyan' | |
end | |
end | |
end | |
Nyan.nyan # => 'nyan' |
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
package main | |
import ( | |
"fmt" | |
) | |
type TailByteReader struct { | |
} | |
func (r *TailByteReader) ReadByte() (c byte, e error) { |
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 Person(firstName, lastName){ | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
Person.prototype.greet = function(){ | |
alert("hello! I'm " + this.firstName + " " + this.lastName); | |
} | |
var p = new Person("shinpei", "maruyama"); |
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 | |
// chords テーブル | |
// id integer | |
// root varchar | |
// quality varchar | |
// | |
// rootには C, C#, D, D#, E....が入る | |
// quality テーブルにはm,Mが入る | |
// このテーブルには、12音 * 2つのqualityで24個のデータを最初から入れておく |
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
// たとえばこんなかんじ | |
int nyan(){ | |
int *p1 = (int *)malloc(sizeof(int)) | |
int *p2 = (int *)malloc(sizeof(int)) | |
int *p3 = (int *)malloc(sizeof(int)) | |
int retval = 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
#include <stdio.h> | |
int main(int argc, char *argv[]){ | |
long l = strtol("string"); | |
int strtol_err = errno; // コピーしとかないといけない | |
// ちょっとなんかやる間にerrnoが書きかわる可能性‥‥ | |
if (strtol_err== EINVAL) { | |
// エラー処理 | |
} else if (strtol_err == ERANGE) { |
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
#include <stdio.h> | |
int main(int argc, char *argv[]){ | |
long l = strtol("string"); | |
// なんかこうごちゃごちゃといろいろやる | |
some_function(l); // ここでおかしなことになる | |
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
function Person(firstName, lastName){ | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
var p = new Person("shinpei", "maruyama"); | |
function nyan(p){ | |
p = new Person("tarou", "yamada"); | |
} |
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 array = [1, 2, 3]; | |
function reAssign(a) { | |
// aに再代入 | |
a = []; | |
} | |
reAssign(array); | |
// reAssignの中の a と 外のarrayは「別の変数」だから | |
// aにほかのものを代入してもarrayには影響がない。 | |
console.log(array); // [1, 2, 3] |
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
// さらに、notesの初期化はコンストラクタでやれば | |
// if 文が減らせて、複雑性が減り、バグを入れ込みにくくなる | |
function Key(){ | |
// snip | |
this.notes = []; | |
// snip | |
} | |
Key.prototype.renderTo = function(cssId) { | |
for(var i=0; i < this.notes.length; i++){ | |
var selector = cssId + " ." + this.notes[i]; |