Skip to content

Instantly share code, notes, and snippets.

View djom202's full-sized avatar

Jonathan Olier djom202

View GitHub Profile
@djom202
djom202 / Gulpfile.js
Created May 2, 2017 14:12 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@djom202
djom202 / Food.js
Created April 4, 2017 19:08 — forked from ryanlanciaux/Food.js
Files for AngularJS blog post.
/*---------------------
:: Food
-> model
---------------------*/
module.exports = {
attributes : {
name: 'STRING',
type: 'STRING',
expiration: 'DATE',
quantity: 'STRING',
@djom202
djom202 / dist.js
Last active March 31, 2017 15:58
Creating a distribution from an options number and an answers count to answer a Qrvey
function dist(num, answersCount){
var perc = Array.apply(null, { length: num }).map(function() {
return parseInt(answersCount / num);
}),
rest = answersCount - (parseInt(answersCount / num) * num);
perc[0] += rest; // for when is a only one result we always the first position.
return {
'perc': perc,
@djom202
djom202 / package.json
Created December 29, 2016 19:44
Commands for run in npm
"scripts": {
"clean": "rimraf dist/*",
"prebuild": "npm run clean -s",
"build": "npm run build:scripts -s && npm run build:styles -s && npm run build:markup -s",
"build:scripts": "browserify -d assets/scripts/main.js -p [minifyify --compressPath . --map main.js.map --output dist/main.js.map] | hashmark -n dist/main.js -s -l 8 -m assets.json \"dist/{name}{hash}{ext}\"",
"build:styles": "stylus assets/styles/main.styl -m -o dist/ && hashmark -s -l 8 -m assets.json dist/main.css \"dist/{name}{hash}{ext}\"",
"build:markup": "jade assets/markup/index.jade --obj assets.json -o dist",
"test": "karma start --singleRun",
@djom202
djom202 / README.md
Created September 29, 2016 13:53
How to install Rails on Mac

Setup Ruby On Rails on macOS 10.12 Sierra

A guide to setting up a Ruby on Rails development environment.

  • Ctrl+S / Cmd+S to save the file
  • Ctrl+Shift+S / Cmd+Shift+S to choose to save as Markdown or HTML
  • Drag and drop a file into here to load it
  • File contents are saved in the URL so you can share files

Overview

@djom202
djom202 / brewInstall.sh
Created September 29, 2016 13:31
How to install Brew in Mac
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@djom202
djom202 / onPreparePromiseConf.js
Created September 27, 2016 14:35
Configuration using a function in onPrepare to set a parameter before
// Configuration using a function in onPrepare to set a parameter before
// testing.
var env = require('./environment.js');
var q = require('q');
// The main suite of Protractor tests.
exports.config = {
seleniumAddress: env.seleniumAddress,
@djom202
djom202 / index.js
Last active September 5, 2016 16:42
A object with a promise of protractor
//***************
// Protractor is global var
//***************
var User = function(){
this.isLogged = function(){
var _defered = protractor.promise.defer();
this.httpRequest(); // Call the http request function
@djom202
djom202 / setEncode.js
Created June 22, 2016 19:40
Encode Username and Password to send header via API Authorization
function setEncode(input) {
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
chr1, chr2, chr3, enc1, enc2, enc3, enc4 = "",
output = "",
i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);