Skip to content

Instantly share code, notes, and snippets.

View dalabarge's full-sized avatar

Daniel LaBarge dalabarge

View GitHub Profile
@dalabarge
dalabarge / leaflet-marker-icon.less
Last active January 4, 2016 09:19
FontAwesome Based Leaflet.js Marker Shadows
/* 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.
*/
@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!'
@dalabarge
dalabarge / route-bindings.md
Created June 25, 2014 17:15
Route Binding Best Pratcies

Route Bindings

// One-line description of route
Route::get('url', [
    'as'     => 'domain.name',
    'before' => [ 'filter' ],
    'uses'   => '\Controller@name' ]);
@dalabarge
dalabarge / Collection.php
Last active June 19, 2018 20:56
Generics in PHP
<?php
namespace Generic;
class Collection implements Contract
{
/**
* Untyped items in collection.
*
* @var array
@dalabarge
dalabarge / pgsql_send_query.php
Last active June 21, 2018 20:03
A pgsql_send_query wrapper that integrates with Laravel's Eloquent models
<?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 / sid.php
Created June 20, 2019 16:21
A UUID to short ID (SID) convertor based on CRC64 to Base36
<?php
/**
* @return array
*/
function crc64Table()
{
$crc64tab = [];
// ECMA polynomial