Skip to content

Instantly share code, notes, and snippets.

View BrandonSurowiec's full-sized avatar

Brandon Surowiec BrandonSurowiec

  • Flint, MI
View GitHub Profile
@apphp
apphp / gist:8765344
Created February 2, 2014 09:34
Create a Database and Assign a User
/*
This is a very simple snippet about how to create a database 1st,
a user and then assign some privileges to the user to allow him/her to
perform some specific actions like insert, create, update, select etc.
Source: http://www.apphp.com/index.php?snippet=mysql-create-database-and-assign-user
*/
-- Create database, user and grant all privileges
CREATE DATABASE database_name;
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
@tevko
tevko / respsizes.js
Last active January 31, 2016 10:31
Dev Tools Snippet to auto-calculate responsive image sizes value on window resize
/**
*
* Paste image class / identifier in IIFE parenthesis at end of function
*
* */
(function(i){"use strict";var img=$(i),sizes=[];window.addEventListener("resize",()=>{var vw=Math.round(((img.offsetWidth*100)/window.innerWidth))+"vw",mq="(min-width: "+window.innerWidth+"px)",value=vw;vw!=="0vw"&&sizes.indexOf(vw)===-1&&(sizes.push(value),console.log(mq,vw))})})("PASTE CLASS OR IDENTIFIER HERE");
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTranslationsTable extends Migration
{
/**
* Run the migrations.
*
@nmendes
nmendes / s3policyexample.json
Last active June 27, 2016 15:27
Example of a Amazon S3 User Policy to use with the ProcessWire AmazonS3Cloudfront Module
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl"
],
@tjlytle
tjlytle / README.md
Last active September 30, 2016 01:24

LaraconUS 'Advice' Demo

If you want to troll your friends with this, here you go. Caution, if [used in a live demo][1], [may][2] [have][3] [unexpected][4] [results][5].

Super Importaint Note: The get() method used here is basically a prototype, so it certianly may change. /warning

App Setup

Add this to composer.json, to bring in both the Nexmo client and Laravel package as their currently in beta:

@martindilling
martindilling / 2015_09_03_142321_create_coupons_table.php
Created September 3, 2015 15:06
Polymorphic Coupons with Eloquent
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCouponsTable extends Migration
{
public function up()
{
Schema::create('coupons', function (Blueprint $table) {
@ericlbarnes
ericlbarnes / countries.php
Created January 26, 2015 20:11 — forked from DHS/PHP Countries Array
PHP Array of country names
<?php
return [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Antigua and Barbuda",
"Argentina",
@sagalbot
sagalbot / Container.php
Last active April 5, 2017 19:35
A bare-bones PHP IoC container.
<?php
interface Container
{
static function bind($name, Callable $resolver);
static function make($name);
}
@jameshulse
jameshulse / Controller.php
Last active July 17, 2017 03:10
Example of non-database bound model binding in Laravel routes
<?php
class Controller
{
function getData(Period $period)
{
return Model::where('created_at', '>', Carbon::create($period->year, $period->month, 1));
}
}
@jasonlemay
jasonlemay / 0) ABC for Sendy with Laravel
Last active July 28, 2017 04:39
Setting up Sendy with Laravel
Setting up Sendy with Laravel
(there might be bugs, I striped out some parts of my code because what I have is more complicated then that, so, sorry if it's broken!)
--
I would recommand creating a database for Sendy only.
Add Sendy's database into your database.php (1)
Create the Campaign model (2), and specify that you want to use Sendy's database (Campaigns are the only thing we really need to create, other things like creating lists can be done through Sendy interface, and there is a PHP library to add subscribers)
Now, it's time to install Sendy, usually somewhere like yourapp.com/sendy or yourapp.com/newsletter