Skip to content

Instantly share code, notes, and snippets.

View kasperlewau's full-sized avatar

Kasper Lewau kasperlewau

View GitHub Profile
@kasperlewau
kasperlewau / gist:11037277
Created April 18, 2014 10:48
angularjs watcher bookmarklet
javascript: (function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
@kasperlewau
kasperlewau / Brewfile
Created March 29, 2014 18:32
Brewfile
tap phinze/cask
tap caskroom/versions
tap KevinSjoberg/formulas
install brew-cask
install git
install node
install imagemagick
install m
install mongodb
@kasperlewau
kasperlewau / wat.js
Last active August 29, 2015 13:56
$scope.$watch initial value
// Runs a fn on the initial value of some prop on the current scope, runs on following changes.
// Server Side
app.get('/wat', function *(next) {
this.body = { wat: "WAT" };
yield next;
});
// Client Side
$scope.test = 'Initval';
@kasperlewau
kasperlewau / pwatch.js
Created February 20, 2014 13:56
tiny lil wrapper to watch a single prop.
// $scope.obj = { a: "A", b: "B" };
var pWatch = function (obj, prop, cb) {
return $scope.$watch(obj + "." + prop, function () {
cb.apply(this, arguments);
});
};
// $scope.pWatch('obj', 'a', function (oldV, newV) {
// do stuffs
@kasperlewau
kasperlewau / fizz.js
Created December 16, 2013 10:28
randomz
function arr (i) { return i ? arr(i-1).concat(i) : [] }
_.each(arr(100), function (x) {
console.log((x % 3 === 0 ? 'Fizz' : '')+(x % 5 === 0 ? 'Buzz' : '') || x);
});
@kasperlewau
kasperlewau / .bash_profile
Last active December 31, 2015 12:18
dotfiles
# [[ -r ~/.bash_prompt ]] && source ~/.bash_prompt
# [[ -s ~/.bashrc ]] && source ~/.bashrc
# [[ -s ~/.exports ]] && source ~/.exports
for file in ~/.{bash_prompt,bashrc,exports}; do
[ -r "$file" ] && source "$file"
done
alias rdbm="be rake db:migrate"
alias rdbt="be rake db:test:prepare"
alias seed="be rake db:seed"
@kasperlewau
kasperlewau / event.js
Created October 30, 2013 11:37
event_exerciser problem
defun answerInvite(v, e) {
var val = e.el.value;
var id = snapshot(v.data).event.id;
server.request({method: "put", path: "events/" + id + "/invitation",
body: {status: val}})
.then(partial(logIt, v));
};
@kasperlewau
kasperlewau / gallery-ctrl.js
Created September 20, 2013 20:24
Testing Restangular within a Controller.
@kasperlewau
kasperlewau / gist:6510460
Last active December 22, 2015 18:08
Error: No module: app
I'm having a go at testing my Angular application. Here's my setup:
* Rails Backend & Folder Structure
* AngularJS(v.1.1.5)
* Restangular
* UI-Router
* Karma
* Jasmine