Skip to content

Instantly share code, notes, and snippets.

function bang(target, name, descriptor) {
var _get = descriptor.get;
descriptor.get = function() {
return _get.call(this) + '!';
}
}
function wrap(pattern) {
return function (target, name, descriptor) {
/**
* __proto__ and prototype
* - the __proto__ property the instance's 'parent' up the prototype chain
* - the prototype property refers what new instances of the type will have their __proto__ set to, i.e. what will be the new instance's 'parent' up the prototype chain
*/
/* Given */
function Object () {}
Object.prototype = {
__proto__: null
_.mixin({
// Get/set the value of a nested property
deep: function (obj, key, value) {
var keys = key.replace(/\[(["']?)([^\1]+?)\1?\]/g, '.$2').replace(/^\./, '').split('.'),
root,
i = 0,
n = keys.length;
@lucassus
lucassus / pull_request.rb
Created March 13, 2014 13:14
Creates pull request from the current local branch
#!/usr/bin/env ruby
require "optparse"
options = Hash.new
parser = OptionParser.new do |opts|
opts.banner = "Usage: pull_request [options]"
opts.on("-i", "--issue=ISSUE", "GitHub issue") do |issue|
options[:issue] = issue
end
'use strict';
var app = angular.module('angularjsTddRecipesApp');
var CommentsCtrl = function($scope, loadComments) {
$scope.load = function() {
var promise = loadComments();
promise.then(function(response) {
<script>
// inject inlined constants
angular.module('app.constants', [])
.constant('contextPath', '${pageContext.request.contextPath}');
</script>
'use strict';
var CreateCtrl = function(List) {
this.List = List;
this.list = new List();
};
angular.extend(CreateCtrl.prototype, {
create: function(list, lists) {
'use strict';
var app = angular.module('glossaryApp');
app.config(function($provide) {
$provide.decorator('$modal', function($delegate) {
var open = $delegate.open;
// decorate newly created modalInstance with some custom methods
<html ng-app="ng-demo-app">
<head>
<title>AngularJS simple app demo</title>
</head>
<body ng-controller="MainCtrl">
<input type="text" ng-model="name" ng-required>
<div>{{name}}</div>
<div ng-controller="ChildCtrl">
<input type="text" ng-model="salut">
<div>{{salutation}}</div>
@lucassus
lucassus / promiseSpec.js
Last active August 29, 2015 14:06
Q, mocha, chai, sinon cheatsheet
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var sinonChai = require('sinon-chai');
chai.use(sinonChai);
var expect = require('chai').expect;
var sinon = require('sinon');