Fix OSX battery draining on sleep due to wifi activity
Install SleepWatcher using Homebrew:
sudo chown -R $(whoami) /usr/local
brew update
brew install sleepwatcher
Start the SleepWatcher service:
<?php | |
// @see: https://github.com/sebastianbergmann/phpunit/issues/4026 | |
// Use `$this->with(...$this->consecutiveParams($args1, $args2))` instead of `$this->withConsecutive($args1, $args2)`. | |
use PHPUnit\Framework\TestCase; | |
class FooTest extends TestCase | |
{ | |
use ConsecutiveParams; |
# Put this inside /bin/test.sh to install Laravel's dependencies before running testsuite in Docker. | |
docker run \ | |
-it \ | |
--rm \ | |
-w /data \ | |
-v ${PWD}:/data:delegated \ | |
--entrypoint /bin/sh \ | |
registry.gitlab.com/grahamcampbell/php:8.1-base -c 'curl -o /tmp/composer-setup.php https://getcomposer.org/installer && php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && composer install' |
version: '3.4' | |
services: | |
miniflux: | |
image: miniflux/miniflux:latest | |
ports: | |
- "80:8080" | |
depends_on: | |
- db | |
environment: | |
- DATABASE_URL=postgres://miniflux:secret@db/miniflux?sslmode=disable |
Install SleepWatcher using Homebrew:
sudo chown -R $(whoami) /usr/local
brew update
brew install sleepwatcher
Start the SleepWatcher service:
<?php | |
trait MetaClass | |
{ | |
protected $__classMethods = array(); | |
static protected $__staticMethods = array(); | |
public function __call($name, $args) | |
{ |
Translations: Korean (by Yongwoo Lee)
Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.
I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).
#!/usr/bin/env bash | |
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/ | |
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c | |
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver | |
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception | |
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal | |
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04 | |
# Versions | |
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE` |
(function($) { | |
$(document).ready(function() { | |
// Highlight Navigation | |
var url = $.parseUrl(document.location); | |
$('a').each(function() { | |
var link = $.parseUrl(this.href); | |
if (link.pathname !== '' && link.pathname === url.pathname) { | |
$(this).siblings().removeClass('active'); | |
$(this).addClass('active'); | |
} |
<?php | |
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html | |
// Start a session (which should use cookies over HTTP only). | |
session_start(); | |
// Create a new CSRF token. | |
if (! isset($_SESSION['csrf_token'])) { | |
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32)); | |
} |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.