Skip to content

Instantly share code, notes, and snippets.

View Rolilink's full-sized avatar

Rolando Perez Rolilink

View GitHub Profile
@Rolilink
Rolilink / gist:4533070
Last active December 11, 2015 02:48
My File
var express = require('express');
var app = express();
var stylus = require('stylus');
var nib = require('nib');
var documentspath = 'src/dcouments'
var docpadInstanceConfiguration = {};
var docpadInstance = require('docpad').createInstance(docpadInstanceConfiguration, function(err,docpadInstance){
if (err) return console.log(err.stack);
// ...
});
@Rolilink
Rolilink / FileStructure
Created September 24, 2013 15:52
my shim config
Folder
| Public
| | Js
| | | app
| | | | views
| | | | | topbar.js
| | | | pages
| | | | | main.js
| | | libs
| | | | backbone.js
@Rolilink
Rolilink / omg.js
Last active August 29, 2015 13:56
OMG
var bcrypt = require('bcrypt'),
SALT_WORK_FACTOR = 10,
crypto = require('crypto'),
validate = require('mongoose-validator').validate;
var Schema = new mongoose.Schema({
name: {type:String,required:true,validate:[validate('len',1,20),validate('regex',/^[A-Za-z ]+$/)]},
password: {type:String,required:true,validate:[validate('len',6,20)]},
username: {type:String,required:true,unique:true,index:true,validate:[validate('len',6,20),validate('regex',/^[a-z A-Z][a-zA-Z0-9_\-]+[a-zA-Z0-9]+$/)]},
email: {type:String,required:true,unique:true,index:true,validate:[validate('isEmail')]},
@Rolilink
Rolilink / controller.js
Created February 14, 2014 17:09
Loading Modules Dynamically
define(function(require){
var runFilters = function(filters){
var _ = require('underscore');
var computedFilters = getFilters(filters);
var result = _.every(computedFilters,function(filter){
return filter();
});
return result;
};
@Rolilink
Rolilink / controller.js
Created February 14, 2014 17:15
Static way
define(function(require){
var runFilters = function(computedFilters){
var result = _.every(computedFilters,function(filter){
return filter();
});
return result;
};
var getFilters = function(filters){
var _ = require('underscore');
def update_myself
@user = current_user
role = Role.find(params[:user][:role_ids]) unless params[:user][:role_ids].nil?
params[:user] = params[:user].except(:role_ids)
if @user.update_attributes(params[:user])
@user.update_plan(role) unless role.nil?
render :json => {success:true}
else
render :json => {success:false}
end
@Rolilink
Rolilink / example
Created July 23, 2014 02:21
example.js
/*global TemplateDashboard, $*/
// on close logic
Backbone.View.prototype.close = function(){
this.remove();
this.unbind();
}
window.TemplateDashboard = {
data:{},
/**
* Remove diacritics (accent and other marks) on characters, and dissociate double characters.
* Based on the character map of http://lehelk.com/2011/05/06/script-to-remove-diacritics/
* but per-character walk (improved performance).
*
* Licensed under WTFPL v2 http://sam.zoy.org/wtfpl/COPYING
*/
var removeDiacritics = (function() {
var diacritics = {"\u24B6":"A","\uFF21":"A","\u00C0":"A","\u00C1":"A","\u00C2":"A","\u1EA6":"A","\u1EA4":"A","\u1EAA":"A","\u1EA8":"A","\u00C3":"A","\u0100":"A","\u0102":"A","\u1EB0":"A","\u1EAE":"A","\u1EB4":"A","\u1EB2":"A","\u0226":"A","\u01E0":"A","\u00C4":"A","\u01DE":"A","\u1EA2":"A","\u00C5":"A","\u01FA":"A","\u01CD":"A","\u0200":"A","\u0202":"A","\u1EA0":"A","\u1EAC":"A","\u1EB6":"A","\u1E00":"A","\u0104":"A","\u023A":"A","\u2C6F":"A","\uA732":"AA","\u00C6":"AE","\u01FC":"AE","\u01E2":"AE","\uA734":"AO","\uA736":"AU","\uA738":"AV","\uA73A":"AV","\uA73C":"AY","\u24B7":"B","\uFF22":"B","\u1E02":"B","\u1E04":"B","\u1E06":"B","\u0243":"B","\u0182":"B","\u0181":"B",
@Rolilink
Rolilink / Dockerfile
Last active August 29, 2015 14:14
loopback-git-base Dockerfile
# LoopBack App Base Image
# Installs StrongLoop and Git
FROM dockerfile/nodejs
#Installing Loopback
RUN npm install -g strongloop
# Installing Git
RUN mkdir /data/git-tmp
WORKDIR /data/git-tmp
@Rolilink
Rolilink / Dockerfile
Created February 2, 2015 18:47
app container
# LoopBack App Base Image
FROM 4dstudios/loopback_app_base
# Create App Directory and CD into it
RUN mkdir /data/app
WORKDIR /data/app
# Clone Master and Install dependencies
RUN git clone https://github.com/Rolilink/remote-job-board.git