Skip to content

Instantly share code, notes, and snippets.

Daniel LaBarge dalabarge

Block or report user

Report or block dalabarge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dalabarge
dalabarge / sid.php
Created Jun 20, 2019
A UUID to short ID (SID) convertor based on CRC64 to Base36
View sid.php
<?php
/**
* @return array
*/
function crc64Table()
{
$crc64tab = [];
// ECMA polynomial
@dalabarge
dalabarge / pgsql_send_query.php
Last active Jun 21, 2018
A pgsql_send_query wrapper that integrates with Laravel's Eloquent models
View pgsql_send_query.php
<?php
$attributes = ['name' => 'John Doe'];
$query = User::where('email', 'john@example.com'); // $query->toSql() --> select * from `users` where `email` = ?
$grammar = $query->getQuery()->getGrammar();
$sql = $grammar->compileUpdate($query->getQuery(), $attributes); // update `users` set `name` = ? where `email` = ?
$bindings = $query->getBindings(); // ['john@example.com']
if( ! array_has($bindings, 'join') ) {
array_set($bindings, 'join', []); // because Grammar stupidly assumes a join binding
}
@dalabarge
dalabarge / Collection.php
Last active Jun 19, 2018
Generics in PHP
View Collection.php
<?php
namespace Generic;
class Collection implements Contract
{
/**
* Untyped items in collection.
*
* @var array
@dalabarge
dalabarge / leaflet-marker-icon.less
Last active Jan 4, 2016
FontAwesome Based Leaflet.js Marker Shadows
View leaflet-marker-icon.less
/* This uses Leaflet.js's markers:
* L.divIcon({
* iconSize: [30, 0],
* className: 'comment',
* html: '<i class="fa fa-fw"></i>'
* });
* to inject a FontAwesome icon into the marker .leaflet-marker-icon.
* It copies that same icon using the :after pseudo element and applies
* a shadow transform to it. Use content to change the icon.
*/
@dalabarge
dalabarge / route-bindings.md
Created Jun 25, 2014
Route Binding Best Pratcies
View route-bindings.md

Route Bindings

// One-line description of route
Route::get('url', [
    'as'     => 'domain.name',
    'before' => [ 'filter' ],
    'uses'   => '\Controller@name' ]);
View Envoy.blade.php
@task('setup')
composer install --no-dev
npm install
php artisan key:generate
migrations
php artisan db:seed
build
git commit -am 'Initial commit.'
git push origin master
echo 'Finished setting up new FooBar project!'
You can’t perform that action at this time.