Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View arjenblokzijl's full-sized avatar

Arjen Blokzijl arjenblokzijl

View GitHub Profile
@arjenblokzijl
arjenblokzijl / instructions.md
Created February 26, 2021 19:49
Separate work and personal git accounts

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 March 16, 2018 20:23
Useful Linux shell commands

Useful Linux shell commands

Move all folder content up one level

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

@arjenblokzijl
arjenblokzijl / processWire-delete-unused-fields.php
Created August 19, 2016 09:17
ProcessWire delete unused Fields
<?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 July 12, 2016 09:19
Basic Process Module Process
<?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 07:15
ProcessWire duplicate role with permissions and field access
<?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 March 16, 2018 20:23
Update ProcessWire $page from CSV
<?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 13:35
Create random dates between in 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 13:33
Save fields in ProcessWire from .csv file
<?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 July 25, 2018 20:36
How To Add SSL to ServerPilot nginx

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 July 30, 2020 19:55
Convert CSV file to PHP associative array
<?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) {