This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
tail -f /var/log/nginx/access.log | awk ' | |
/" 2/ {print "\033[32m" $0 "\033[39m"; next;} | |
/" 3/ {print "\033[37m" $0 "\033[39m"; next;} | |
/" 4/ {print "\033[33m" $0 "\033[39m"; next;} | |
/" 5/ {print "\033[31m" $0 "\033[39m"} | |
' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$attendees = [ | |
// insert attendee list here | |
]; | |
$winnerIndex = random_int(0, count($attendees)-1); | |
$winner = $attendees[$winnerIndex]; | |
echo "\n\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Parses resource identifiers of the format: | |
* RESOURCE=s3://username:password@domain/resource | |
*/ | |
if ($resource = getenv('RESOURCE')) { | |
// strip off the namespace, assume it's not needed (e.g 's3', 'mysql') | |
$identifier = explode('://', $resource)[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
<title>My Web App</title> | |
</head> | |
<body> | |
<div id="react-app"></div> | |
<script src="/js/bundle.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Acme\Models; | |
/** | |
* In Laravel 4.2: app/src/Models/User.php | |
* | |
* In Laravel 5.x: app/Models/User.php | |
*/ | |
class User | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Console; | |
use Illuminate\Console\Scheduling\Schedule; | |
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | |
class Kernel extends ConsoleKernel | |
{ | |
/** | |
* The Artisan commands provided by your application. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Providers; | |
use Illuminate\Routing\Router; | |
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | |
class RouteServiceProvider extends ServiceProvider | |
{ | |
/** ... etc */ | |
public function map(Router $router) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** in app/Http/Middleware/GuestMiddleware.php */ | |
class GuestMiddleware implements Middleware | |
{ | |
public function handle($request, Closure $next) | |
{ | |
if (\Auth::check()) { | |
return new RedirectResponse(url('/')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Models; | |
class Article extends Model | |
{ | |
/** etc... */ | |
public function associatedUsers() | |
{ | |
return $this->belongsToMany('...'); | |
} | |
/** etc... */ |