Skip to content

Instantly share code, notes, and snippets.

View bjrmatos's full-sized avatar

BJR Matos bjrmatos

View GitHub Profile
@bjrmatos
bjrmatos / app.js
Created May 12, 2014 16:10 — forked from robertklep/app.js
Express vhosting
var express = require('express');
var app = express();
var app2 = express();
app.use(express.vhost('app1.example.com', require('./app1').app));
app.use(express.vhost('app2.example.com', app2));
app2.get('/', function(req, res) {
res.send('app 2');
@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 / 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 / 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) {
import redis
import json
register = {
"src" : "nodebots-dev.mx",
"target" : "http://127.0.0.1:4500/"
}
registerAsStr = json.dumps(register)
@bjrmatos
bjrmatos / redirect-on-navigation,js
Last active August 29, 2015 14:07
redirects for phantomjs
var system = require('system'),
webpage = require('webpage'),
t,
mainUrl,
address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
@bjrmatos
bjrmatos / gist:1dfd15059b5a9969a6a0
Last active May 24, 2022 19:21 — forked from georgeOsdDev/gist:9501747
Disable JS execution in console
// Disable javascript execution from console
// http://kspace.in/blog/2013/02/22/disable-javascript-execution-from-console/
var _z = console;
Object.defineProperty( window, "console", {
get : function(){
if( _z._commandLineAPI ){
throw "Sorry, Can't exceute scripts!";
}
return _z;
},
@bjrmatos
bjrmatos / loading.md
Last active August 29, 2015 14:08 — forked from thomasboyt/loading.md
Loading state in Flux

I've been struggling to come up with a good pattern for handling loading state in Flux (specifically using Fluxxor, though I think this is an issue for any implementation).

When I say "loading state," what I mean is state in a store that tracks:

  • Whether the data handled by the store was loaded
  • Whether the store is currently attempting to load data
  • Whether the data loaded successfully or errored
  • The error message, if it errored

Here's my first (very simple) pass at this, a store mixin called LoadingStoreMixin.js: