Skip to content

Instantly share code, notes, and snippets.

View daniel-aranda's full-sized avatar

Daniel Aranda daniel-aranda

View GitHub Profile
@daniel-aranda
daniel-aranda / README.md
Last active February 25, 2016 06:05
Node.js :: This is how you should use anonymous functions if you do not want to lose the scope of this

Traditional callbacks:

asyncObject.method(function(){
  //TODO: stuff
});

Binding the scope to currentObject

@daniel-aranda
daniel-aranda / array.without.php
Created May 22, 2015 19:29
PHP :: Implementing array function "without"
<?php
/**
* @author: Daniel Aranda - https://gist.github.com/daniel-aranda
*
* Implements an array utility to return an array without a given element.
*
* Usage example:
*
* $array = [1, 2, 3, 4, 5];
* print_r( array_without($array, 3) );
@daniel-aranda
daniel-aranda / instructions.txt
Last active December 27, 2022 22:06
Git split components :: Using PHP Splitter to forward Laravel component
#INSTRUCTIONS
Those instructions would move the Laravel Cache component into a desired repo, given a specific tag
1. Go to any folder that you desire, for example: /tmp/splitter/
2. Run: git clone git@github.com:daniel-aranda/PHP-Git-Component-Splitter.git
3. Run: composer update
4. Copy from this gist "splitter.config.json" and put on your cloned folder under bin.
5. Run: php bin/daniel-splitter.php --tag v5.0.0
@daniel-aranda
daniel-aranda / example.php
Created March 24, 2015 18:10
Using PHP native functions as dependencies
/**
* Mocking a PHP native function is a trivial(and a headache) topic around PHPUnit
* I figured a way and wanted to share it, threat the functions as
* Closure dependencies.
**/
class SomeClass{
private $sleep;
@daniel-aranda
daniel-aranda / .bash_profile
Last active August 29, 2015 14:16
.bash aliases
#Daniel Aranda aliases
#This is thinking for me as shortcut of the commands I use more, I do not mind to share it public to
#bring ideas.
#Git status short version and include the current branch name
alias gs="git status -s -b"
#Git add to stage all modified files also deleted files
alias gadd="git add . && git add -u .;"
@daniel-aranda
daniel-aranda / benchmark.php
Last active August 29, 2015 14:05
PHP :: fwrites vs buffer in arrays
<?php
function test_fwrite($file, $total){
$time_start = microtime(true);
if( file_exists($file) ){
unlink($file);
}
$fp = fopen($file, 'a');