Skip to content

Instantly share code, notes, and snippets.

View jgatjens's full-sized avatar
🏠
working from home!

Jairo Gätjens jgatjens

🏠
working from home!
View GitHub Profile
@jgatjens
jgatjens / watchers.js
Created October 4, 2014 20:53
Angular total watchers
(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);
});
}
angular.forEach(element.children(), function(childElement) {
@jgatjens
jgatjens / server.js
Created September 22, 2014 02:13
server.js
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var httpProxy = require('http-proxy');
/* This configuration allow you to configure browser sync to proxy your backend */
var proxyTarget = 'http://server/context/'; // The location of your backend
var proxyApiPrefix = 'api'; // The element in the URL which differentiate between API request and static file request
#!bash
#
# git-flow-completion
# ===================
#
# Bash completion support for [git-flow](http://github.com/nvie/gitflow)
#
# The contained completion routines provide support for completing:
#
# * git-flow init and version
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@jgatjens
jgatjens / direcory_tag.rb
Created February 10, 2014 22:03
jekyll-plugin loop_directory
#usage:
#{% loop_directory directory:images iterator:image filter:*.jpg sort:descending %}
# <img src="{{ image }}" />
#{% endloop_directory %}
module Jekyll
class LoopDirectoryTag < Liquid::Block
include Liquid::StandardFilters
Syntax = /(#{Liquid::QuotedFragment}+)?/
@jgatjens
jgatjens / require-conf.js
Created December 17, 2013 16:22
Using the shim for non-AMD libraries and cdn calls.
require.config({
paths: {
// use cdn default | fall back local copy
"jquery": [
'//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js',
'lib/jquery'
]
"backbone": "vendor/backbone",
"underscore": "vendor/underscore"
},
@jgatjens
jgatjens / base.js
Created October 30, 2013 21:04
Prototypal Inheritance
var BaseModel = function(type){
this.type = !type ? "BaseModel" : type ;
};
BaseModel.prototype.sayHello = function() {
return "Hello " + this.type;
};
var User = function() {
@jgatjens
jgatjens / Gruntfile.js
Created October 25, 2013 20:06
Gruntjs - Setup server, compass, livereload
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
/*global module:false*/
module.exports = function(grunt) {
@jgatjens
jgatjens / hw2-2.js
Created August 27, 2013 20:50
Write a program that finds the document with the highest recorded temperature for each state, and adds a "month_high" field for that document, setting its value to true.
// Write a program that finds the document with the highest
// recorded temperature for each state, and adds a "month_high"
// field for that document, setting its value to true.
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/weather', function(err, db) {
if(err) throw err;
var cursor = db.collection('data').find({});
@jgatjens
jgatjens / Requirejs - shim
Last active December 17, 2015 17:09
Using the shim for non-AMD libraries and cdn calls.
require.config({
paths: {
// use cdn default | fall back local copy
"jquery": [
'//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js',
'lib/jquery'
]
"backbone": "vendor/backbone",
"underscore": "vendor/underscore"
},