Skip to content

Instantly share code, notes, and snippets.

@danharper
danharper / a-FormatController.php
Last active August 1, 2017 12:06
A Laravel Controller which allows you to display API/report data in multiple formats. For example, you may display a preview as HTML, and offer buttons to download as CSV and JSON.
<?php
// this is the base controller which parses output to HTML/CSV/JSON depending on the format in the URL
use Illuminate\Support\Collection;
class FormatController extends Controller {
protected $fileName = 'export';
protected $view = 'reports.output';
@danharper
danharper / a.md
Last active September 2, 2020 17:13
Laravel Queue Supervisor

Install Supervisor with sudo apt-get install supervisor. Ensure it's started with sudo service supervisor restart.

In /etc/supervisord/conf.d/ create a .conf file. In this example, laravel_queue.conf (contents below). Give it execute permissions: chmod +x laravel_queue.conf.

This file points at /usr/local/bin/run_queue.sh, so create that file there. Give this execute permissions, too: chmod +x run_queue.sh.

Now update Supervisor with: sudo supervisorctl reread. And start using those changes with: sudo supervisorctl update.

@danharper
danharper / after.blade.php
Created March 20, 2014 13:02
Declarative Blade Extensions
@usingPerRow(4)
@foreach ($images as $image)
@incrementPerRow()
@whenStartOfRow
<tr>
@closeStartOfRow
<td><img src="{{ $image->url }}"></td>

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@danharper
danharper / ex.md
Last active August 29, 2015 14:00
how i feel css pre-processors should be: extending the language via namespaced (prefix) attributes & functions - NOT via @include stuff

In raw CSS:

.foo {
  background: -webkit-linear-gradient(red, green) left repeat;
  background: linear-gradient(red, green) left repeat;
  -webkit-transition: all 0.8s;
  -moz-transition: all 0.8s;
  transition: all 0.8s;
 color: green;

OS X 10.10 Guide

Here's what I did to get things working.

1. Install Xcode 6

Yep, over at: https://developer.apple.com

2. Install the Command Line Tools (CLT)

#!/bin/sh
# deploy.sh
N="`readlink \"$1\"`"
mv -T "$1.stage" "$1"
ln -s "$N" "$1.stage"
rm -rf "$N"
cp -aH "$1" "$N"
@danharper
danharper / keybase.md
Created September 23, 2014 20:36
keybase.md

Keybase proof

I hereby claim:

  • I am danharper on github.
  • I am danharper (https://keybase.io/danharper) on keybase.
  • I have a public key whose fingerprint is 4EC0 F75A E4A4 CF06 0F41 BCB9 9596 CB4A 8D08 3A0A

To claim this, I am signing this object:

<?php
// Version A: Facades everywhere - typical Laravel 4.2 style
// routes.php
Route::get('payments', 'BillingController@recentPayments');
// BillingController.php
class BillingController {
@danharper
danharper / ffo.html
Created October 23, 2014 19:38
191 chars. Not selectable due to psuedo elements.
<!doctype html>
<title></title>
<style>
*{display:block;}
title:before{content:"<!doctype html><title></title>";}
style:before{content:"<style>";}
style:after{content:"\3C/style>";}
</style>