Skip to content

Instantly share code, notes, and snippets.

View bjrmatos's full-sized avatar

BJR Matos bjrmatos

View GitHub Profile
@bjrmatos
bjrmatos / post-merge
Created May 15, 2014 04:02 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@bjrmatos
bjrmatos / media.styl
Created May 24, 2014 03:45
Stylus - Mixin for media queries
// Functions for ease manipulation of media-queries in stylus
media($q, $mediatype = '')
if $mediatype == ''
unquote("@media " + $q + "{")
else
unquote("@media " + $mediatype + " and " + $q + "{")
endmedia()
unquote("}")
@bjrmatos
bjrmatos / .gitignore
Created June 4, 2014 02:23
My .gitignore for node.js
# Logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
@bjrmatos
bjrmatos / recursive.js
Last active August 29, 2015 14:04
Recursive function that don't overflow the call stack
function isEvenInner (num) {
if (num === 0) {
return true;
}
if (num === 1) {
return false;
}
return function() {
@bjrmatos
bjrmatos / icons.sass
Created July 22, 2014 04:54 — forked from nickawalsh/icons.sass
Sprite Icons - SASS
@import compass
$icons: sprite-map("icons/*.png")
$icons-hd: sprite-map("icons-hd/*.png")
i
background: $icons
display: inline-block
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi)
background: $icons-hd
@bjrmatos
bjrmatos / SassMeister-input.scss
Created August 2, 2014 21:54
SASS - Media query mixin
// ----
// Sass (v3.3.12)
// Compass (v1.0.0.alpha.21)
// ----
// Breakpoints map
// @type Map
$breakpoints: (
// Regular breakpoints
"baby-bear": "(max-width: 500px)",
@bjrmatos
bjrmatos / nodejs-cheatsheet.js
Last active August 29, 2015 14:05 — forked from LeCoupa/nodejs-cheatsheet.js
Node.js cheatsheet
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@bjrmatos
bjrmatos / app.js
Last active August 29, 2015 14:05 — forked from stongo/app.js
Mongoose example
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@bjrmatos
bjrmatos / callbackHell.js
Last active August 29, 2015 14:06 — forked from robinduckett/callbackHell.js
callback hell and async module
// Callback Hell. You and I both know it's hell.
// Here's a secret: Escape Callback Hell...
// ... by using classes, you fucking jackass.
// This is shit:
fs.readdir('tmp', function(err, list) {
async.map(list, function(item, cb) {
cb(null, item.toUpperCase());
}, function(err, results) {
@bjrmatos
bjrmatos / navigation.jade
Created September 19, 2014 22:20
Active navigation - Jade
//In your routes.js (or wherever) define an array of objects representing your nav like such:
var navLinks = [
{ label: 'Home', key: 'home', path: '' },
{ label: 'About', key: 'about', path: '/about' },
{ label: 'Contact', key: 'contact', path: '/contact' }
]
// Pass the navLinks variable to your view, as well as the key of the item you'd like hilighted: (or put in app.locals)