Skip to content

Instantly share code, notes, and snippets.

View freekmurze's full-sized avatar

Freek Van der Herten freekmurze

View GitHub Profile
@freekmurze
freekmurze / deploy.php
Last active February 5, 2021 02:43
A sample deploy.php file that can be used with Deployer (http://deployer.in)
<?php
/*
* Define the servers
*/
server('production-web', '<your server url>')
->path('<path to the project on your server>')
->user('<user on the server>')
->pubKey();
/*
@freekmurze
freekmurze / validate.md
Last active February 15, 2018 17:29
A handy validate function for Laravel 5
/**
 * Validate some data.
 *
 * @param string|array $fields
 * @param string|array $rules
 * @return bool
 */
function validate($fields, $rules)
{
@freekmurze
freekmurze / Upgrade PHP 5 to 7 on a Forge provisioned server.md
Last active February 20, 2017 04:17
Upgrade PHP 5 to 7 on a Forge provisioned server

sudo add-apt-repository ppa:ondrej/php

sudo apt-get install php7.0

sudo apt-get install php7.0-gd

sudo apt-get install php7.0-mysql

sudo apt-get install php-memcached

@freekmurze
freekmurze / Spark helper functions.php
Last active May 3, 2016 16:31
Spark helper functions
<?php
/**
* @return \App\User|null
*/
function currentUser()
{
return request()->user();
}
@freekmurze
freekmurze / undot.php
Last active June 24, 2022 05:04
Undot
<?php
function undot(array $dottedArray)
{
$undottedArray = [];
foreach ($dottedArray as $key => $value) {
Arr::set($undottedArray, $key, $value);
}
@freekmurze
freekmurze / curry.php
Created December 17, 2016 20:51
curry.php
<?php
function curry($f, $argument)
{
return function (...$arguments) use ($f, $argument) {
return $f(...array_merge([$argument], $arguments));
};
}
function add(...$numbers)
@freekmurze
freekmurze / Envoy.blade.php
Created March 23, 2017 13:50
Multi server zero downtime Envoy script
@setup
require __DIR__.'/vendor/autoload.php';
(new \Dotenv\Dotenv(__DIR__, '.env'))->load();
$appName = "my-app.com";
$repository = "spatie/{$appName}";
$baseDir = "/home/forge/{$appName}";
$releasesDir = "{$baseDir}/releases";
$currentDir = "{$baseDir}/current";
$newReleaseName = date('Ymd-His');
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Subscriptions - [email protected]</title>
</head>
<body>
<outline text="PHP" title="PHP">
<outline htmlUrl="http://frederickvanbrabant.com" title="frederickvanbrabant.com" xmlUrl="http://frederickvanbrabant.com/feed.xml" type="rss" text="frederickvanbrabant.com"/>
<outline htmlUrl="http://mattallan.org" title="mattallan.org" xmlUrl="http://mattallan.org/feed.xml" type="rss" text="mattallan.org"/>
<outline title="asked.io" xmlUrl="https://asked.io/rss" type="rss" text="asked.io"/>
@freekmurze
freekmurze / GitHub.icls
Created May 7, 2018 09:07
GitHub PhpStorm colorscheme
<scheme name="GitHub" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2018-05-07T11:01:49</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2018.1.0.0</property>
<property name="modified">2018-05-07T11:02:04</property>
<property name="originalScheme">GitHub</property>
</metaInfo>
<option name="LINE_SPACING" value="1.4" />
@freekmurze
freekmurze / Check.php
Last active February 28, 2021 02:54
Refactored Oh Dear! code
<?php
class Check
{
public function needsToRun(): bool
{
if (!$this->belongsToTeamOnActiveSubscriptionOrOnGenericTrial()) {
return false;
}