Skip to content

Instantly share code, notes, and snippets.

View satoshun's full-sized avatar
🤖

Sato Shun satoshun

🤖
View GitHub Profile
@satoshun
satoshun / 0_reuse_code.js
Created March 20, 2014 09:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@satoshun
satoshun / nil_receiver.go
Created December 13, 2014 12:28
go: nil_receiver
package main
import "log"
type Object struct {
}
func (o Object) value() {
log.Println(o, "call value receiver")
}
@satoshun
satoshun / gist:5128329
Created March 10, 2013 12:12
social intent
package com.example.mysocialintent.test;
import android.app.Activity;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import com.example.mysocialintent.MainActivity;
import com.example.mysocialintent.libs.MySocialIntent;
package com.example.mysocialintent.libs;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import android.app.Activity;
import android.content.Intent;
public enum MySocialIntent {
import java.util.*;
class EnumPractice{
private enum singleton{
INSTANCE;
public void show(){
System.out.println("enum show");
}
}
var a = (function(){
return 100;
}());
var b = {
o: (function(){
var local = 100;
return local * 2;
}())
};
@satoshun
satoshun / test_singleton.js
Created March 23, 2013 03:57
javascript singleton
describe('decorator', function() {
// body...
it('singleton1', function(done) {
var Car = function(){
var instance = this;
this.a = 100;
Car = function(){
return instance;
};
};
@satoshun
satoshun / test_iterator.js
Created March 23, 2013 05:48
test iterator
describe('iterator', function() {
it('test', function() {
var Iter = function(data){
this.index = 0;
this.data = data;
};
Iter.prototype = {
next: function(){
var elem = this.data[this.index];
this.index += 1;
@satoshun
satoshun / test_observer.js
Created March 24, 2013 11:41
test observer
describe('design pattern', function () {
var testData = null;
it('observer', function(){
var Observer = function(){
this.subscribers = [];
};
Observer.prototype = {
publish: function(data){
var i = 0,
len = this.subscribers.length;
@satoshun
satoshun / ex_knockout2.js
Created March 27, 2013 15:18
knockoutjs
$(document).ready(function() {
var models = {
names: ko.observableArray([
{"name": "name1"},
{"name": "name2"}
])
};
ko.applyBindings(models);
setTimeout(function(){