Skip to content

Instantly share code, notes, and snippets.

View aj07mm's full-sized avatar

Julio Marins aj07mm

View GitHub Profile
@aj07mm
aj07mm / isSumPossibleZ.js
Last active January 21, 2016 02:02
isSumPossibleZ
//retunr 1 , if there exits a certain group of Z numbers selected from the array
//such that their sum equals N
//HackerRank passing 13/14
exports.isSumPossibleZ = function(A, n, Z) {
var sum = function(A, pastSums, Z){
//each execution run 2 by default, so Z is Z-2
Z = Z-2;
if(Z <= 0){
Z = 0;
}
//HackerRank 2/4
exports.isSumPossible = function (A, n) {
//exceptions
var exception1 = A.length<2;
var exception2 = !(A instanceof Array)
var exception3 = A instanceof Number
if(exception1 || exception2 || exception3){
return 0
}
//combinate
@aj07mm
aj07mm / gist:b1bb8fe70157b51f4325
Created January 23, 2016 14:14
excuse to mail a unanswered email
just wanted to make sure my last message dind't slip thourgh the cracks.
Would you mind letting me know if it's of interest? NO worries if not :)
@aj07mm
aj07mm / .sh
Created January 23, 2016 14:15
Laravel routines
php artisan make:migration create_nerds_table --table=nerds --create
php artisan make:model Nerd
php artisan make:controller NerdController
php artisan route:list
php artisan serve
php artisan config:cache
composer dump-auto or composer dump-auto -o
2. php artisan cache:clear
3. php artisan config:clear
@aj07mm
aj07mm / .json
Created February 12, 2016 02:29
babel.js start with "npm start"
{
"dependencies": {
"babel-cli": "^6.0.0",
"babel-preset-es2015": "^6.0.0"
},
"scripts": {
"start": "babel-node --presets es2015 ./app.js"
}
}
@aj07mm
aj07mm / .js
Created February 16, 2016 20:01
braces
function braces(arrBraces) {
var result = []
for (var i = arrBraces.length - 1; i >= 0; i--) {
var strBraces = arrBraces[i];
result.push(checkBalance(strBraces));
};
return result.reverse()
};
@aj07mm
aj07mm / .js
Created February 17, 2016 02:09
bitwise swap
function swap(a,b){
return a^=b, b^=a, a^=b;
}
@aj07mm
aj07mm / .js
Created February 17, 2016 03:13
Call by Sharing
// http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language
// https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing
'use strict'
var swap = function(a, b){
var c = a;
b = a;
a = b;
};
@aj07mm
aj07mm / web-servers.md
Created February 18, 2016 13:32 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@aj07mm
aj07mm / gist:77364e79e4614d11d860
Created February 23, 2016 19:37
recursion javascript
var graphToArray = function (listNode, memo) {
//run once
if(listNode.next == null){
memo.push(listNode.val)
return memo;
}
//go down
//but memo here call stacks above the current one
return memo.concat(graphToArray(listNode.next, memo))
};