Skip to content

Instantly share code, notes, and snippets.

View alberto1el's full-sized avatar

Alberto alberto1el

View GitHub Profile
@alberto1el
alberto1el / Mongodb 2.6.1 river for ElasticSearch 1.1.1
Last active August 29, 2015 14:01
Installing MongoDB with ElasticSearch working, but went back to mongo 2.4.9 and es 1.0.3
I was not able to get mongo 2.6.1 and elasticsearch 1.1.1 running with the 2.0.0 river plugin, so i went with mongo 2.4.9 and es 1.0.3 and the 2.0.0 river plugin
#install mongo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
#sudo apt-get install mongodb-org
sudo apt-get install mongodb-10gen
sudo apt-get install mongodb-10gen=2.4.9
echo "mongodb-10gen hold" | sudo dpkg --set-selections
@alberto1el
alberto1el / Neo4j
Last active August 29, 2015 14:01
Instalacion de Neo4j en Ubuntu o debian (on vagrant box)
#vagrant box: box: puphpet/ubuntu1204-x64
# box_url: puphpet/ubuntu1204-x64
#From: http://debian.neo4j.org/
#Neo Technology provides this Debian repository, to make it easy to install Neo4j. There are 3 repositories:
#testing
# Milestone builds for the upcoming Neo4j release.
#stable
# The current stable Neo4j release. You should choose this by default.
#oldstable
@alberto1el
alberto1el / gist:e52051e243093c6f605a
Created July 14, 2014 23:41
Remove .svn directories from repository
You can also issue the line below straight from the Command Prompt:
FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"
#Add the Tokutek package signing key.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 505A7412
#Add an entry for the TokuMX package repository for your release (wheezy, precise, quantal, raring, saucy, or trusty).
echo "deb [arch=amd64] http://s3.amazonaws.com/tokumx-debs $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/tokumx.list
#Update apt and install TokuMX.
sudo apt-get update
sudo apt-get install tokumx
mongo
@alberto1el
alberto1el / gist:d5ae07da6fdfa05535b1
Last active August 29, 2015 14:15
Cool Regex PHP Session to Laravel Session
if\(isset\(\$_SESSION\[("|')regr("|')\]\[("|')([a-zA-Z_]+)("|')\]\)\)(| )echo \$_SESSION\[("|')regr("|')\]\[("|')([a-zA-Z_]+)("|')\]
if(Session::has('regr.$4'))echo Session::get('regr.$4')
//AnotherOne
if\(\$_POST\['([a-zA-Z_]+)'\]\!\=''\)\{\$_SESSION\["regr"\]\['([a-zA-Z_]+)'\] \= \$_POST\['([a-zA-Z_]+)'\];
}else{$mensaje.='Falto Nombre Completo del distribuidor';$continua=false;}
if(Request::has('$1') && Request::input('$1')!=''){Session::put('regr.$1', Request::input('$1') ) ; } //replace
@alberto1el
alberto1el / l5 on aws ec2
Last active August 29, 2015 14:25
Laravel 5.1 on EC2 July 2015
Boot up an ubuntu instance ( I used ubuntu-trusty-14.04-amd64-server-20150325 (ami-df6a8b9b) )
———- Installing Apache ———-
$ sudo apt-get install apache2
———- Installing Latest PHP ———-
$ sudo add-apt-repository ppa:ondrej/php5
$ sudo apt-get update
$ sudo apt-get install php5 libapache2-mod-php5
———- Installing PHP Mcrypt ext. ———-
$ sudo apt-get install php5-mcrypt
@alberto1el
alberto1el / gist:b472f5768360d038fa6c5b280277a901
Created November 11, 2016 01:03
Artisan Commands debugging on PHPStorm with XDEBUG
#http://stackoverflow.com/a/20120264
#where server_name stands for name of the server in PhpStorm project conifuguration
$ XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=server_name" php -dxdebug.remote_host=`echo $SSH_CLIENT | cut -d "=" -f 2 | awk '{print $1}'` artisan command
@alberto1el
alberto1el / PolymorphicRelationshipInPowerBI.txt
Created June 26, 2019 21:08
A PowerBI formula to handle polymorphic relationships using conditional columns (MySQL source)
let
Source = MySQL.Database("127.0.0.1:33060", "dbname", [ReturnSingleDatabase=true]),
table = Source{[Schema="dbname",Item="location_logs"]}[Data],
#"Added Conditional Column1" = Table.AddColumn(table, "location_name",
each if [locatable_type] = "condition_one" then (
let conditionOneID = [locatable_id] in
Table.SelectRows(#"dbname source_table_one", each [id] = conditionOneID)
){0}[name]
@alberto1el
alberto1el / s3PresignedPUTUriLaravel.php
Created April 16, 2020 05:50
get an S3 presigned PUT url in Laravel (I dont know if there is a more elegant way but this seems to work... did not test the actual upload but it did return a uri)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
class S3PresignedURIController extends Controller
{
@alberto1el
alberto1el / DedupWithGroupConcat
Created August 4, 2020 00:59
A way to find duplicates in MySQL using group concat (its been fast so far, with tens of thousands records)
/*
THE SETUP:
An "order_status_logs" table with the following columns: order_id, status_id, created_at
There is no constraint for order_id and status_id so you can have the same order and status multiple times on "order_status_logs"
THE OBJECTIVE:
A query that returns the order_status_logs records that have duplicates (same order_id and status_id) for a known status_id
*/