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 / gist:4601347
Created January 23, 2013 02:33
Regular Expresion - mark tag text
(?<=<h2>).+(?=</h2>)
@jgatjens
jgatjens / sprite-example.scss
Last active December 13, 2015 18:18
Compass - Custom sprite
@import "compass/utilities/sprites/base";
$icons: sprite-map("images/icons/*.png", $layout: smart);
[class^="icon-"] {
display: inline-block;
background: $icons;
}
@each $i in sprite_names($icons) {
@jgatjens
jgatjens / class.js
Created February 23, 2013 04:47 — forked from mcgrew/class.js
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
* Usage exmaples: http://ejohn.org/blog/simple-javascript-inheritance/
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@jgatjens
jgatjens / script.js
Created March 11, 2013 16:44
Mongodb - script collection multiples query
var conn = new Mongo();
var db = conn.getDB("test");
var myCursor = db.images.find();
myCursor.forEach(
function(myDoc) {
// print( "images: " + tojson(myDoc) );
var myAlbum = db.albums.findOne( { "images": myDoc._id } );
@jgatjens
jgatjens / gist:5145268
Created March 12, 2013 17:59
Nodejs - Static File Server
var express = require(' express');
var app = express();
app.configure(function() {
app.set(' view engine', 'jade');
app.use(express.static(__dirname + '/ public'));
});
app.get('/', function(req, res) {
res.render(" index.jade", {
layout: false
});
@jgatjens
jgatjens / Module no dependencies
Created May 24, 2013 15:18
No dependencies? Object literal? No problem!
define({
forceChoke: function() {
},
forceLighting: function() {
},
forceRun: function() {
}
@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"
},
@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 / 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 / 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() {