Skip to content

Instantly share code, notes, and snippets.

@sgelbart
sgelbart / README.md
Created Mar 13, 2018 — forked from joyrexus/README.md
collapsible markdown
View README.md

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@sgelbart
sgelbart / firebase-example.html
Created Dec 10, 2017
A simple firebase example for reading and writing database records realtime.
View firebase-example.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Order Form</title>
View ValidateCominationOfColumns.php
<?php
Validator::extend('combinedUnder3', function ($attribute, $value, $parameters, $validator)
{
$data = $validator->getData();
return ($data->number1 + $data->number2) < 3;
});
?>
View gist:6a37a8216aa8f1fa406b
**STATIC TABLE SEEDS**
problem
There's no elegant way for seeding application data that you want versioned and mirrored on all our servers. You can create traditional seeds but you end up reseeding all your application data each time (which is annoying with large tables) or you have to do some wonky work arounds for each server.
characteristics of STATIC tables
- table data should match per server, the same way file data does
- data should never be added by users
- code data is dependent upon
- there should not be any coupling based on this data, e.g., it should not send any alerts/messages that would depend upon “create” events etc
@sgelbart
sgelbart / LaravelEasyGlobalScope.php
Last active Sep 22, 2016
Any easy implementation for laravel in-model global scopes (basic testing in Laravel 4.2)
View LaravelEasyGlobalScope.php
<?php
//USAGE
//in your model
public function scopeGlobal($query)
{
//todo: there may be a bug where you can't use nested wheres..try with ->where(function($query){return MyModel::noEasyGlobal();}
return MyModel::noEasyGlobal()->where('is_published',1); //replace this with whatever criteria you ahve