Skip to content

Instantly share code, notes, and snippets.

View Braunson's full-sized avatar

Braunson Yager Braunson

View GitHub Profile
@Braunson
Braunson / migration_example.php
Created December 21, 2017 18:21
Need to loop through multiple Laravel models to do the same update on all of their results? In this example it's updating the address country id
<?php
// Models to run through
$models = collect([
'contact',
'business',
]);
// Loop through the models
$models->each(function ($value, $key) use ($keys) {
@Braunson
Braunson / searchreplacedb2.php
Created October 23, 2017 02:05
interconnectit/Search-Replace-DB 2.0.1 - Migrated from the MySQL Extension to PDO
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
layout title permalink
checklist_page
The Side Project Marketing Checklist
/marketing-checklist/

Pre-Launch

Market Research

@Braunson
Braunson / pwd-faas.md
Created January 11, 2017 02:55 — forked from alexellis/pwd-faas.md
pwd-faas-quickstart.md

This is a Quickstart guide for FaaS functions as a Service on Play-with-docker.com

Head over to http://play-with-docker.com/ and start a new session. Add one host to start with.

# docker swarm init # use --advertise-addr here and pick the 10.x IP address range

# git clone https://github.com/alexellis/faas
# cd faas
# ./deploy_stack.sh
@Braunson
Braunson / routing_patterns.php
Created November 21, 2016 20:20 — forked from lucasdavies/routing_patterns.php
Routing patterns from laravel-tricks.com
<?php
// This is what you might have right now
Route::get('users/{id}', 'UserController@getProfile')->where('id', '[\d+]+');
Route::get('products/{id}', 'ProductController@getProfile')->where('id', '[\d+]+');
Route::get('articles/{slug}', 'ArticleController@getFull')->where('slug', '[a-z0-9-]+');
Route::get('faq/{slug}', 'FaqController@getQuestion')->where('slug', '[a-z0-9-]+');
// and many more, now imagine you'll have to change the rule
// Instead, you could have a handy list of patterns and reuse them everywhere:
@Braunson
Braunson / ClearBeanstalkdQueueCommand.php
Created November 18, 2016 02:23 — forked from lukaswhite/ClearBeanstalkdQueueCommand.php
Clear a Beanstalkd Queue in Laravel
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ClearBeanstalkdQueueCommand extends Command {
/**
@Braunson
Braunson / nginx-s3.conf
Created February 24, 2016 22:00 — forked from surjikal/nginx-s3.conf
Nginx - Wildcard subdomains, basic auth and proxying to s3. Set a policy to only allow your server's IP.
server {
listen 80;
server_name *.foo.example.com;
# We need this to resolve the host, because it's a wildcard.
# This is google's DNS server.
resolver 8.8.8.8;
include /etc/nginx/includes/proxy.conf;
@Braunson
Braunson / github-remove-diff-markers-bookmarklet.js
Created December 4, 2015 00:47 — forked from jkingsman/github-remove-diff-markers-bookmarklet.js
Remove the '+' and '-' from GitHub diff view; helpful when copying large swaths of code from a diff.
javascript:(function(){for(var elements=document.getElementsByClassName("blob-code-inner"),i=0;i<elements.length;i++)(elements[i].parentNode.classList.contains("blob-code-addition")||elements[i].parentNode.classList.contains("blob-code-deletion"))&&(elements[i].innerHTML=elements[i].innerHTML.substring(1));})();
@Braunson
Braunson / content-length-size.md
Created October 29, 2015 13:38 — forked from voronianski/content-length-size.md
What happens if you serve content with a different length than the Content-Length header?

@jakearchibald done a bit of research around this:

###Loading a page with Content-Length < actual content length

  • Chrome: Truncated content - no indication of error
  • Firefox: Truncated content - no indication of error
  • Safari: Truncated content - no indication of error
  • IE: Truncated content - no indication of error

###Loading a page with Content-Length > actual content length