Skip to content

Instantly share code, notes, and snippets.

View arjenblokzijl's full-sized avatar

Arjen Blokzijl arjenblokzijl

View GitHub Profile
@arjenblokzijl
arjenblokzijl / pf2pt.php
Created July 8, 2014 18:17
Simple script to convert Page field to Pagetable
<?php
include("index.php");
$pages = wire()->pages;
$stadiums = $pages->find("template=template, field.count>0");
$ptf = "template";
$ptt = "fieldname";
<?php
/**
* ProcessWire example demonstration module
*
* PageListActionHook autoload module once installed will remove "new" action from second level pages
* using the template "basic-page"
*
*/
@arjenblokzijl
arjenblokzijl / Remove system label from template
Last active August 29, 2015 14:08
Remove system label from template
<?php
$template = $templates->get("template_name"); // Insert template name here
$template->flags = Template::flagSystemOverride;
$template->flags = false; // Set flag to false
$template->save();
@arjenblokzijl
arjenblokzijl / wget.sh
Last active August 29, 2015 14:18
Download complete website to local files with wget
# Thanks to: http://snipplr.com/view.php?codeview&id=23838
# --recursive: download the entire Web site.
# --domains website.org: don't follow links outside website.org.
# --no-parent: don't follow links outside the directory tutorials/html/.
# --page-requisites: get all the elements that compose the page (images, CSS and so on).
# --html-extension: save files with the .html extension.
# --convert-links: convert links so that they work locally, off-line.
# --restrict-file-names=windows: modify filenames so that they will work in Windows as well.
# --no-clobber: don't overwrite any existing files (used in case the download is interrupted and resumed).
@arjenblokzijl
arjenblokzijl / gist:b0bd9d2db524b42c6a4b
Created July 27, 2015 08:01
War tested PHP regular expressions
Dutch Chamber of Commerce > /(?<!\d)\d{8}(?!\d)/
Dutch postal code > /^[1-9][0-9]{3}[\s]?[A-Za-z]{2}$/i
General URL > @(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@i
LinkedIn URL > /(ftp|http|https):\/\/?((www|\w\w)\.)?linkedin.com(\w+:{0,1}\w*@)?(\S+)(:([0-9])+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
@arjenblokzijl
arjenblokzijl / font-awesome.txt
Last active August 29, 2015 14:25
ProcessWire Hanna Code export for Font Awesome usage
!HannaCode:font-awesome:eyJuYW1lIjoiZm9udC1hd2Vzb21lIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxuaWNvbj1cIlwiXG5jb2xvcj1cIlwiXG5oY19hdHRyKlwvXG48P3BocFxuXG5pZiAoJGljb24pIHtcblxuICAgIGlmICgkY29sb3IpIHtcbiAgICAgICAgJGNvbG9yID0gXCJzdHlsZT0nY29sb3I6JGNvbG9yJ1wiOyBcbiAgICB9XG4gICAgXG4gICAgZWNobyBcIjxpIGNsYXNzPSdmYSAkaWNvbicgJGNvbG9yPjxcL2k+XCI7XG5cbn0ifQ==/!HannaCode
@arjenblokzijl
arjenblokzijl / splitcsv.sh
Created August 13, 2015 11:18
Split CSV file and preserve header
tail -n +2 file.txt | split -l 4 - split_
for file in split_*
do
head -n 1 file.txt > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file
done
@arjenblokzijl
arjenblokzijl / add-extension.sh
Last active August 29, 2015 14:27
Recursively add file extension to all files
# http://stackoverflow.com/questions/1108527/recursively-add-file-extension-to-all-files
find . -type f -exec mv '{}' '{}'.jpg \;
@arjenblokzijl
arjenblokzijl / workflow.md
Last active November 9, 2015 11:03
Single mainline Git workflow

Workflow

Single mainline Git workflow

proces

The single mainline workflow constists of:

  • a single mainline branch ("master")
  • one short-lived feature branch per feature with a speaking branch name
@arjenblokzijl
arjenblokzijl / gist:5207400
Last active December 15, 2015 05:09
Example of how to add children to the homepage in ProcessWire. See: http://processwire.com/talk/topic/3065-direct-children-of-default-front-page/.
<?php
// Get the homepage
$homepage = $pages->get("/");
// Get the all the children of home
$children = $homepage->children;
// Get all the homepage children who need to be under home in the menu
$homePageChildren = $homepage->children("homechild=1");