Skip to content

Instantly share code, notes, and snippets.

View mreis1's full-sized avatar

Reis mreis1

View GitHub Profile
@mreis1
mreis1 / controller.js
Created March 30, 2016 17:33 — forked from BobNisco/controller.js
onLongPress AngularJS Directive - Great for mobile!
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@mreis1
mreis1 / blog-webpack-2.md
Created November 23, 2016 19:49 — forked from xjamundx/blog-webpack-2.md
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@mreis1
mreis1 / hero.ts
Created May 19, 2017 15:50 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@mreis1
mreis1 / gist:ac2da3c82e752606b2386b1dddf8c0c4
Created May 22, 2017 10:19 — forked from levicook/gist:4132037
modeling friends and calculating mutual friends w/ mongodb
// ------------------------------------------------------------------
// Friend collection, where _id is a user.Id and Friends is a list, of user.Id.
// Note: friending and unfriending is a two step operation in this scheme:
> db.friends.find()
{ "_id" : 1, "friends" : [ 2, 3, 4 ] }
{ "_id" : 2, "friends" : [ 1, 3, 5 ] }
{ "_id" : 3, "friends" : [ 1, 2, 4, 5 ] }
{ "_id" : 4, "friends" : [ 1, 3, 5 ] }
{ "_id" : 5, "friends" : [ 2, 3, 4 ] }
@mreis1
mreis1 / bcast.js
Created June 7, 2017 14:03 — forked from josuesasilva/bcast.js
Broadcast UPD Node.js
var dgram = require('dgram');
var server = dgram.createSocket("udp4");
// server
server.bind(function() {
server.setBroadcast(true)
server.setMulticastTTL(128);
broadcastNew();
});
@mreis1
mreis1 / crypto-stream.js
Created July 26, 2017 20:09 — forked from chris-rock/crypto-stream.js
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');
@mreis1
mreis1 / mongo-autostart-osx.md
Created August 21, 2017 07:12 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@mreis1
mreis1 / node-cluster-messaging.js
Created January 25, 2018 18:02 — forked from jpoehls/node-cluster-messaging.js
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@mreis1
mreis1 / mongod.conf
Created March 19, 2018 13:23 — forked from cesare/mongod.conf
MacOSX launchd plist file to start MongoDB server
dbpath = /var/mongo/data
logpath = /var/mongo/logs/mongod.log
@mreis1
mreis1 / gist:b89b62393f962c60e95cede7ab7b7800
Created April 4, 2018 12:31 — forked from kylefox/gist:4512777
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff