Skip to content

Instantly share code, notes, and snippets.

@arjenblokzijl
arjenblokzijl / instructions.md
Created Feb 26, 2021
Separate work and personal git accounts
View instructions.md

Edit global gitconfig file

git config --global --edit

# This is Git's per-user configuration file.
[user]
	name = Your Work Name
	email = user@workemail.com
@arjenblokzijl
arjenblokzijl / useful-linux-shell-commands.md
Last active Mar 16, 2018
Useful Linux shell commands
View useful-linux-shell-commands.md

Useful Linux shell commands

Move all folder content up one level

mv foo/* foo/.[^.]* . && rm -r foo/

View processWire-delete-unused-fields.php
<?php namespace ProcessWire;
include("../index.php");
foreach (wire('fields') as $f) {
if (count($f->getFieldgroups())) continue;
echo $f->name . "<hr>";
wire('fields')->delete($f);
}
@arjenblokzijl
arjenblokzijl / process-module.php
Created Jul 12, 2016
Basic Process Module Process
View process-module.php
<?php
class ProcessReleases extends Process implements Module {
public static function getModuleInfo() {
return array(
'title' => "Releases",
'version' => "0.0.1",
'summary' => "Show releases for the mydatafactory application.",
'autoload' => false,
@arjenblokzijl
arjenblokzijl / processwire-duplicate-role.php
Last active May 30, 2016
ProcessWire duplicate role with permissions and field access
View processwire-duplicate-role.php
<?php namespace ProcessWire;
include('index.php');
$contractingRole = wire('roles')->get('contracting-user');
$managerRole = wire('roles')->get('manager');
$managerRole->of(false);
$managerRole->permissions = $contractingRole->permissions;
$managerRole->save();
@arjenblokzijl
arjenblokzijl / update-page-from-csv.php
Last active Mar 16, 2018
Update ProcessWire $page from CSV
View update-page-from-csv.php
<?php namespace ProcessWire;
include('index.php');
/**
* CSV format
*
* title,datetime_matching_date,page_matching_person
* 464,12/24/2014,1132
* 1750,5/9/2016,1132
@arjenblokzijl
arjenblokzijl / create-random-dates.php
Created May 18, 2016
Create random dates between in PHP
View create-random-dates.php
<?php
// Forgot where this came from
function rand_date($min_date, $max_date) {
$min_epoch = strtotime($min_date);
$max_epoch = strtotime($max_date);
$rand_epoch = rand($min_epoch, $max_epoch);
@arjenblokzijl
arjenblokzijl / save-fields-from-csv.php
Created May 18, 2016
Save fields in ProcessWire from .csv file
View save-fields-from-csv.php
<?php
// Bootstrap ProcessWire
include 'index.php';
// Process CSV
$rows = array_map('str_getcsv', file('fields.csv'));
$header = array_shift($rows);
$fields = array();
foreach ($rows as $row) {
@arjenblokzijl
arjenblokzijl / ssl-serverpilot.md
Last active Jul 25, 2018
How To Add SSL to ServerPilot nginx
View ssl-serverpilot.md

How To Add SSL to ServerPilot nginx

Requirements

  1. Domain (i.e. example.com)
  2. Subdomain(s): (i.e. www.example.com)
  3. Username
  4. App name

Create the Certificate

@arjenblokzijl
arjenblokzijl / convert-csv-file-to-php-associative-array.php
Last active Jul 30, 2020
Convert CSV file to PHP associative array
View convert-csv-file-to-php-associative-array.php
<?php
/* Thanks to http://steindom.com/articles/shortest-php-code-convert-csv-associative-array */
ini_set('auto_detect_line_endings', TRUE);
$rows = array_map('str_getcsv', file('myfile.csv'));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {