Skip to content

Instantly share code, notes, and snippets.

View carlospliego's full-sized avatar
🚀

carlos carlospliego

🚀
View GitHub Profile
@carlospliego
carlospliego / flat.js
Last active October 30, 2017 20:00
Flatten n-depth array es6
// Checks the equality of arrays based on value
const assertEqual = (arr1, arr2) => {
if (arr1.length !== arr2.length)
return false;
for (var i = arr1.length; i--;) {
if (arr1[i] !== arr2[i])
return false;
}
@carlospliego
carlospliego / chuckNorris.js
Last active October 26, 2017 21:54
Creating a Chuck Norris themed Slack app using Webtask.io
"use strict";
const rp = require("request-promise");
const Promise = require("bluebird");
// Get Random Chuck Norris Quote
const getRandomChuckNorrisQuote = () => {
return rp({
uri: "https://api.chucknorris.io/jokes/random",
json: true
@carlospliego
carlospliego / gisttools.js
Created May 31, 2016 19:50
FileProxy ( javaScript )
var FileProxy = function () {
this.stream = function (source, sourceHeaders, destinationHeaders, res) {
var rem;
res.writeHead(200, destinationHeaders);
rem = request(source, sourceHeaders);
rem.on('data', function (chunk) {
res.write(chunk);
});
@carlospliego
carlospliego / gist:3e9134bb64c966f46169
Created September 24, 2015 18:54
Setup NODE on AMAZON EC2
#EC2 Node Setup Guide
##Install Node and NPM
* `sudo yum update`
* `sudo yum install gcc-c++ make`
* `sudo yum install openssl-devel`
* `sudo yum install git`
* `git clone git://github.com/joyent/node.git`
* `cd node`
* `git pull origin master`
@carlospliego
carlospliego / fileModel.js
Created July 12, 2014 18:47
File Model allows you to bind <input type="file" file-model="myfile" /> to a file Object.
// Thanks http://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs
.directive('fileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function(){
scope.$apply(function(){
@carlospliego
carlospliego / gist:864569e6409e2bd13efe
Created July 8, 2014 19:39
AngularJS Conditional Classes
ng-class="{selected: $index==selectedIndex}"
ng-class="{admin:'enabled', moderator:'disabled', '':'hidden'}[user.role]"
thank you: http://stackoverflow.com/a/8309832/1883201
@carlospliego
carlospliego / timeout.js
Last active August 29, 2015 14:03
AngularJS Timout
'use strict';
app.run(function($interval){
// Timeout
var countDown = 4, limit = 0, timer;
timer = $interval(function(){
if(countDown<=limit){
// Trigger
$interval.cancel(timer);
}
@carlospliego
carlospliego / holderFix.js
Created July 6, 2014 08:00
HolderJs fix for angularJS
'use strict';
app.directive('holderFix', function () {
return {
link: function (scope, element, attrs) {
Holder.run({ images: element[0], nocss: true });
}
};
});