Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am armincifuentes on github.
  • I am acc (https://keybase.io/acc) on keybase.
  • I have a public key whose fingerprint is C65E 541A 1097 FA99 C253 BA59 4050 C8B8 5457 A3ED

To claim this, I am signing this object:

@armincifuentes
armincifuentes / non-destructive_migrations.php
Created May 13, 2015 20:51
Non-destructive, conditional migration for Laravel
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Zones extends Migration {
/**
* Run the migrations.
*
@armincifuentes
armincifuentes / gist:68aaabbddc76d4916718
Created May 15, 2015 20:05
Formato request Centinela
{
"id_local" : "123",
"imagen" : "archivo.jpg-O-arvhivo.png",
"observaciones" : "Un texto de que paso",
"georeferencia" : {
"latitud" : "23.234522",
"logitud" : "-12.44334"
},
"ultima_aplicacion_producto" : "2014-12-15 15:45:12",
"fecha_real_tomada" : "2014-12-15 15:45:12",
@armincifuentes
armincifuentes / eloquent_manythroughmany.php
Last active August 29, 2015 14:23
Eloquent manyThroughMany()
<?php
/*
* manyTroughMany()
*
* Enables access to distant relations
* using many-to-many pivot tables.
*
* Proposed by @terion-name at Laravel.io Forums
* http://laravel.io/forum/03-04-2014-hasmanythrough-with-many-to-many
<option value=""></option>
<option value="ALGARROBO">ALGARROBO</option>
<option value="ALHUE">ALHUE</option>
<option value="ALTO BIOBIO">ALTO BIOBIO</option>
<option value="ALTO DEL CARMEN">ALTO DEL CARMEN</option>
<option value="ALTO HOSPICIO">ALTO HOSPICIO</option>
<option value="ANCUD">ANCUD</option>
<option value="ANDACOLLO">ANDACOLLO</option>
<option value="ANGOL">ANGOL</option>
<option value="ANTOFAGASTA">ANTOFAGASTA</option>
@armincifuentes
armincifuentes / angular_watcher_sample.js
Created December 29, 2015 20:13
Angular Watcher syntax
$scope.$watch(function() {
return variable;
}, function(newValue, oldValue) {
// do things
}
});
@armincifuentes
armincifuentes / word-count.js
Created March 8, 2017 20:07
Count words in a HTML text body
function wordCount(text) {
return text
.replace(/[–,;.:!¡¿\-\?\(\)]/g, '') // remove punctuation
.replace(/<[^>]+>/g, ' ') // convert tags into whitespaces
.split(/\s/) // split across whitespaces
.filter(word => word.length) // remove empty keys
.length;
}

Tweets Content Type

Database

Initially I'd go with ContentRequest -> ContentTweets -> ContentNode -> ContentNodeRevision:


                                     ContentNode     ContentNodeRevision
                                   /               /
ContentRequest --&gt; ContentTweets --- ContentNode --- ContentNodeRevision
@armincifuentes
armincifuentes / InstitutionPolicy.php
Created November 22, 2017 14:16
Las políticas definen los permisos para ejecutar acciones
<?php
namespace App\Policies;
use App\User;
use App\Institution;
use Illuminate\Auth\Access\HandlesAuthorization;
class InstitutionPolicy
{
@armincifuentes
armincifuentes / gist:fe781ccb522e4252dab4e030ef7947b4
Created December 15, 2017 00:24
Remove local branches not on master
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d