Skip to content

Instantly share code, notes, and snippets.

View aurbano's full-sized avatar
🎯
ML

Alejandro U. Alvarez aurbano

🎯
ML
View GitHub Profile
@aurbano
aurbano / addHash.js
Created April 18, 2015 11:05
Add the hash to the url
// Check if url includes #/
if(window.location.hash.length < 1 || window.location.hash == ''){
window.location = window.location.origin + window.location.pathname + '#/' + window.location.search;
}
@aurbano
aurbano / .zshrc
Created November 8, 2014 21:16
My .zshrc file
# start_time="$(date +%s)"
# Antigen — A zsh plugin manager
export ANTIGEN_DEFAULT_REPO_URL=https://github.com/sharat87/oh-my-zsh.git
source ~/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo declared above.
@aurbano
aurbano / timeBetween.php
Last active May 13, 2024 01:48
Display the time between two dates in a human readable format (i.e. 3 seconds, 4 days, 1 week... )
<?php
/**
* Calculate the elapsed time between two timestamps
* and display in a pretty human way.
* @param integer $start Initial timestamp
* @param integer $end Final timestamp, set to -1 for current time.
* @return string Formatted elapsed time.
*/
function timeBetween($start, $end=-1){
if($end < 0) $end = time();
@aurbano
aurbano / expressProxy.js
Last active September 21, 2021 17:00
Nodejs + Express : Simple proxy
/**
* Simple image proxy for Nodejs
* @param {Express} app Express app
* @return {function}
*/
var http = require('http'),
url = require('url');
module.exports = function (app) {
app.get('/proxy/:image', function (request_from_client, response_to_client) {
@aurbano
aurbano / ageFromTimestamp.php
Created September 15, 2014 15:29
Calculate age in PHP from timestamp
<?php
function getAge($birth){
$t = time();
$age = ($birth < 0) ? ( $t ($birth * -1) ) : $t - $birth;
return floor($age/31536000);
}
@aurbano
aurbano / demo.php
Last active August 29, 2015 14:06
Display all files in folder
<?php
include('displayFiles.php');
displayFiles('pictures');
@aurbano
aurbano / demo.html
Last active August 18, 2016 15:39
jQuery Draggable bring to front
<script type="text/javascript">
$('.drag').bind('click',function(){ bringFront($(this), '.drag'); });
</script>
@aurbano
aurbano / neo4j-pathFiltering.cypher
Last active December 5, 2016 15:06
Neo4j: Return paths that contain only 1 node with a given property
// Match all the paths you are interested in, store them as p
// then set n.property to the appropriate value.
// the final 1 means how many nodes with that property/value you want in the paths
MATCH p=(c)-[:REL_TYPE*]-(n)
WHERE LENGTH(FILTER(n IN EXTRACT(n IN nodes(p) | n) WHERE n.property = "value"))=1
RETURN DISTINCT n
@aurbano
aurbano / AndroidEmulatorLaunch.bat
Last active August 29, 2015 13:58
Android Emulator launch batch script using a proxy and a custom AVD
@ECHO OFF
ECHO Launching Emulator
ECHO Using AVD: AVD_for_4_WVGA_Nexus_S
emulator -avd "AVD_for_4_WVGA_Nexus_S" -verbose -http-proxy "http://20.42.128.36:8080" -netfast -gpu on -no-boot-anim -noaudio
PAUSE
@aurbano
aurbano / print_json.php
Last active August 29, 2015 13:57
PHP implementation of print_r to allow customization of the results
<?php
function print_json($json) {
if (is_array($json) || is_object($json)) {
echo "<table width=100%>";
$type = 'Array';
if(is_object($json)) $type = 'Object';
echo '<tr><td colspan=2 style="background-color:#333333;">
<strong><font color=white>'.$type.'</font></strong>
</td></tr>';
foreach ($json as $k => $v) {