Skip to content

Instantly share code, notes, and snippets.

View stilliard's full-sized avatar
🐝

Andrew Stilliard stilliard

🐝
View GitHub Profile
@stilliard
stilliard / jsonToTable.php
Created October 9, 2012 13:24
JSON to HTML table
<?php
/**
* JSON data to html table
*
* @param object $data
*
*/
function jsonToTable ($data)
{
@stilliard
stilliard / fullNameToFirstName.php
Created April 19, 2012 12:47
PHP - Get a users first name from the full name
<?php
/**
* Get a users first name from the full name
* or return the full name if first name cannot be found
* e.g.
* James Smith -> James
* James C. Smith -> James
* Mr James Smith -> James
* Mr Smith -> Mr Smith
@stilliard
stilliard / setup-2gb-swap-partition.sh
Last active September 26, 2023 10:47
Setup swap partition
# 2gb example
# ref: https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=2048k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
@stilliard
stilliard / github-projects-col-widths-userscript.js
Created June 5, 2018 00:08
Slightly decrease widths of github project board columns
// ==UserScript==
// @name Decrease GitHub projects column widths
// @namespace https://www.wildfireinternet.co.uk/
// @version 0.1
// @description By default the column widths on project boards on github are too big, this decreases them a little
// @author Andrew
// @match https://github.com/*/*/projects/*
// @grant none
// ==/UserScript==
semantic-commit = "!f() { \
if [ \"$3\" != \"\" ]; then \
git commit -S -m \"$1($2): $3\"; \
else \
git commit -S -m \"$1: $2\"; \
fi \
}; f"
chore = semantic-commit chore
@stilliard
stilliard / scrape.php
Created May 20, 2020 11:20
Scrape some blog posts and their images
<?php
//
// Quickly download some blog posts
//
// setup:
// mkdir -p images/post-{content,logos} # for images
// mkdir out # for the csv output
// composer init -q
// composer require voku/simple_html_dom
@stilliard
stilliard / gdrive-backup-setup.sh
Last active May 8, 2020 22:24
Backup server files with Google Drive
# ref: https://github.com/prasmussen/gdrive
# prerequisite:
# In google drive, setup your folder for storing the backups
# Then grab the code from the url e.g. https://drive.google.com/drive/folders/xxxxx where xxxxx is the code
# This code will be used later in the cron command, keep it secret, keep it safe
# install gdrive sync for backups
wget https://drive.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA -O /usr/local/bin/gdrive
chmod 755 /usr/local/bin/gdrive
@stilliard
stilliard / index.html.twig
Created August 2, 2019 11:50
Page sub category lists in REC
{% include "html/helpers/sub-categories-list.html.twig" with {'parent': page.products_shown_cat_id } %}
@stilliard
stilliard / new-ssh-user.md
Last active July 30, 2019 11:03
New ssh user setup via github key

Set newusername as the account name you want the user to have on the server, & newusergithub as that persons github account name. This then takes their public key used with github and allows the user to login to the server via their ssh key.

newusername=bob
newusergithub=bobsgh

sudo useradd -m -d /home/$newusername -s /bin/bash $newusername
cd /home/$newusername/
sudo mkdir .ssh
<form method="get">
  <input type="search" name="search" value="{{ filters.search | escape }}">
  <button type="submit">Search</button>
  <a href="{{ module.link }}">reset</a>
</form>