Skip to content

Instantly share code, notes, and snippets.

View sandervanhooft's full-sized avatar

Sander van Hooft sandervanhooft

View GitHub Profile
@mpociot
mpociot / README.md
Last active December 6, 2022 22:45
A Scriptable widget to show the upcoming Laracon talks

Laracon Scriptable Widget

Usage

  1. Install and download the free Scriptable app on your iOS device.
  2. Inside the app, press the "Plus" icon to create a new script
  3. Paste the content of the JS file into the script
  4. Place a Scriptable widget on your home screen
@webdevmatics
webdevmatics / Multiform.php
Last active January 6, 2022 12:51
Livewire multiform #livewire
<?php
namespace App\Http\Livewire;
use App\Customer;
use Livewire\Component;
class Multiform extends Component
{
public $name;
@sandervanhooft
sandervanhooft / CanAssertFlash.php
Last active January 27, 2020 18:01
Assert flash for Laracasts/flash
<?php
namespace Tests;
trait CanAssertFlash
{
protected function assertFlash($level, $message, $important = false, $title = null, $overlay = false)
{
$expectedNotification = [
'title' => $title,
@gilbitron
gilbitron / ApiController.php
Last active July 21, 2020 01:05
ApiController Template for Laravel Spark
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
abstract class ApiController extends Controller
@gaejabong
gaejabong / laracast-theme.icls
Created January 31, 2016 12:32
Laracast theme updated
<scheme name="laracasts-theme-updated" version="142" parent_scheme="Default">
<option name="LINE_SPACING" value="1.7" />
<option name="EDITOR_FONT_SIZE" value="15" />
<option name="CONSOLE_FONT_NAME" value="Menlo" />
<option name="CONSOLE_FONT_SIZE" value="10" />
<option name="CONSOLE_LINE_SPACING" value="1.4" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<colors>
<option name="ADDED_LINES_COLOR" value="292d38" />
<option name="ANNOTATIONS_COLOR" value="8b999f" />
@RadGH
RadGH / short-number-format.php
Last active April 9, 2024 11:28
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@mudge
mudge / EachCons.php
Created July 17, 2014 14:32
Iterate over an array as a sliding window of element pairs.
<?php
$a = array(1, 2, 3);
$pairs = array_map(null, $a, array_slice($a, 1));
/**
* Prints:
* (1,2)(2, 3)(3, )
*/
foreach ($pairs as list($x, $y)) {
echo "({$x}, {$y})";
@trey
trey / happy_git_on_osx.md
Last active February 18, 2024 10:46
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@victorbstan
victorbstan / php_object_to_array.php
Created December 17, 2010 04:18
recursively cast a PHP object to array
<?php
/*
This function saved my life.
found on: http://www.sitepoint.com/forums//showthread.php?t=438748
by: crvandyke
It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?!
*/
$array = json_decode(json_encode($object), true);