Skip to content

Instantly share code, notes, and snippets.

View fakenickels's full-sized avatar
💭
hello this is a mic test, are you listening

Gabriel Rubens Abreu fakenickels

💭
hello this is a mic test, are you listening
View GitHub Profile
@fakenickels
fakenickels / swap.js
Created April 26, 2014 16:53
Swap macro with Sweet.js
macro swap {
rule { $x and $y } => {
var tmp = $x;
$x = $y;
$y = tmp
}
}
// Let's go!
var a = "a",
@fakenickels
fakenickels / isNull.js
Created May 3, 2014 16:27
Gist for Medium post
function isNull( str ){
return str === null ? true : false;
}
@fakenickels
fakenickels / tmpl_engine.js
Created June 19, 2014 19:37
The most simple template engine
function tmpl(text, o){
return text.replace(/({(.+)})/gm, function( exp, conj, innerExp ){
return eval(innerExp);
});
}
@fakenickels
fakenickels / security.js
Created July 13, 2015 14:09
ongoworks:security
Security.defineMethod("ifHasUserId", {
fetch: [],
transform: null,
deny: function (type, args, userId, document) {
return userId !== arg;
}
});
@fakenickels
fakenickels / argumentschema.js
Last active August 29, 2015 14:25
Schema for arguments, say goodbye to if's crazyness
ArgumentsSchema = function(args, schema, extra){
var orderedArgs = {};
for(var arg in args){
for(var field in schema){
if(schema.hasOwnProperty(field)){
if(args[arg].constructor === schema[field]){
orderedArgs[field] = args[arg];
}
}
@fakenickels
fakenickels / es2015_meteor_session.js
Created September 27, 2015 00:06
Meteor Session similar in ES2015
SessionHandler = {
_deps: new Tracker.Dependency,
get(target, name){
this._deps.depend();
return target[name];
},
set(target, name, value){
target[name] = value;
this._deps.changed();
// @locus: server
if(Meteor.isServer){
Tracker.autorun(() => {
CollectionObserved.find();
collectAndSaveData();
});
function collectAndSaveData(){
var aggregateData = CollectionObserved.aggregate(...);
var aggregateDocId = ...;
@fakenickels
fakenickels / command.sh
Created October 20, 2015 13:07
Jenkins shell script to test Meteor packages
if [ ! -d "spacejam" ]; then
git clone https://github.com/practicalmeteor/spacejam.git --depth=1
fi
cd spacejam/
npm link
cd ../
spacejam test-packages ./
@fakenickels
fakenickels / git_move_all.sh
Last active February 23, 2016 18:19
Move all git files to `app/` root directory
#!/bin/sh
for file in `g ls-files`; do
mkdir -p $(dirname app/$file)
g mv "$file" "app/$file" -f
done
# Note: also do a normal move for files in .gitignore
@fakenickels
fakenickels / .zshrc
Created January 4, 2016 16:24
My dots
export ZSH=/home/gabriel/.oh-my-zsh
ZSH_THEME="bureau"
plugins=(git bower common-aliases meteor npm node nyan sudo wd)
# User configuration
alias gfd="g flow feature diff"
export PATH="/home/gabriel/.nvm/versions/node/v4.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
# export MANPATH="/usr/local/man:$MANPATH"