Skip to content

Instantly share code, notes, and snippets.

View sinon_test_pattern.coffee
sinon = require 'sinon'
# class stubbing
class MockClass
method: ->
method2: ->
sinon.stub(MockClass.prototype, 'method').withArgs(1).returns 42
obj = new MockClass
console.log obj.method(1) #=> 42
View simple_grunt_task.coffee
# in gruntfile.coffee
{exec} = require('child_process')
runCommand = (exp, done) ->
exec exp, (error, stdout, stderr) ->
return done(true) if error or stderr
done(false,stdout)
grunt.registerMultiTask 'test', 'test command', ->
conf = @
@mizchi
mizchi / injector.scala
Last active Aug 29, 2015 — forked from anonymous/injector.scala
simple inejctor
View injector.scala
import scala.reflect.{classTag, ClassTag}
object Injector {
private val rootInjector = new Injector(None)
def createInjector = rootInjector.createChild(rootInjector)
def mapValue[T:ClassTag](instance:T): Unit =
rootInjector.mapValue[T](instance)
}
class Injector(val parent:Option[Injector]) {
@mizchi
mizchi / 0_reuse_code.js
Created Mar 20, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mizchi
mizchi / javascript_resources.md
Created Mar 20, 2014 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.
View javascript_resources.md

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
View dummy.d.ts
declare module Foo {
export class Hoge {
name:string;
message:string;
constructor();
f(str:string):string;
}
}
View function.d.ts
declare module Foo {
export class Hoge {
f(str:string, n: number, obj: Object): number;
s: string;
//f(name:string): number;
}
}
View hello.rs
fn main() {}
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
View hello.rs
fn main() {}
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}