Skip to content

Instantly share code, notes, and snippets.

Avatar

Cam Findlay camfindlay

View GitHub Profile
View Creating a static copy of a dynamic website.md

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@camfindlay
camfindlay / macos_high_sierra_apache_php_brew_2018.md
Created Sep 18, 2019 — forked from karlhillx/macos_high_sierra_apache_php_brew_2018.md
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL
View macos_high_sierra_apache_php_brew_2018.md

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

View gist:a8c080435960fe87388474839418f0f0
Lots of stack traces and error messages for CKAN, followed by a comment about how I fixed it (that time).
NB don't email me privately for help - ask on StackOverflow #ckan instead.
David
File "/vagrant/src/ckan/ckan/templates/home/snippets/search.html", line 1, in top-level template code
{% set tags = h.get_facet_items_dict('tags', limit=3) %}
File "/vagrant/src/ckan/ckan/lib/helpers.py", line 949, in get_facet_items_dict
if not c.search_facets or \
File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
@camfindlay
camfindlay / nginx_modsite.sh
Created May 21, 2017
Adds commands to enable and disable nginx vhosts similar to a2ensite etc.
View nginx_modsite.sh
#!/bin/bash
##
# File:
# nginx_modsite
# Description:
# Provides a basic script to automate enabling and disabling websites found
# in the default configuration directories:
# /etc/nginx/sites-available and /etc/nginx/sites-enabled
# For easy access to this script, copy it into the directory:
View scheme.jsonld
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://project-open-data.cio.gov/v1.1/schema/catalog.json#",
"title": "Project Open Data Catalog",
"description": "Validates an entire collection of Project Open Data metadata JSON objects. Agencies produce said collections in the form of Data.json files.",
"type": "object",
"dependencies": {
"@type": [
"@context"
]
@camfindlay
camfindlay / GoogleAnalyticsExtension.php
Created Apr 7, 2016
Example of custom Google Analytics integration for SilverStripe CMS
View GoogleAnalyticsExtension.php
<?php
class GoogleAnalyticsExtension extends DataExtension {
private static $db = array(
'GoogleAnalyticsTrackingID' => 'Varchar(11)',
);
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.GoogleAnalytics', TextField::create('GoogleAnalyticsTrackingID')->setDescription('e.g. UA-XXXXX-XX'));
@camfindlay
camfindlay / gist:50bf3dd1cfaa42addcf7
Created Aug 27, 2015
Switch to SQLite3 for testing when a query string is passed in
View gist:50bf3dd1cfaa42addcf7
if (Director::isDev()) {
if (isset($_GET['db']) && $db = $_GET['db']) {
if ($db == 'sqlite3') {
$databaseConfig['type'] = 'SQLite3Database';
$databaseConfig['memory'] = true;
}
}
@camfindlay
camfindlay / gist:4cef980c1fbabca5bdbe
Created Aug 26, 2015
Get change log messages for github module releases
View gist:4cef980c1fbabca5bdbe
git log --left-right --cherry-pick --oneline --pretty=format:"%h: %s (%an)" branch1...branch2
@camfindlay
camfindlay / gist:4041dfd154e0d176cd81
Last active Aug 29, 2015
Simple deploy script for SilverStripe
View gist:4041dfd154e0d176cd81
#/bin/sh
# Requires: git, composer, sspak, php
echo "Taking a backup"
d=$(date +%Y%m%d%H%M%S)
sspak save /home/bitnami/htdocs ~/backup/$d.sspak
cd ~/htdocs
git fetch
echo "Deploying production release branch"
@camfindlay
camfindlay / post-receive
Created Aug 9, 2015
Git post-receive hook for simple SilverStripe deployment
View post-receive
#!/bin/sh
#Deploy
git --work-tree=/path/to/webroot --git-dir=/path/to/repo.git checkout -f <branch>
#Run composer and dev/build
cd /path/to/webroot
composer install --no-dev --prefer-dist
php ./framework/cli-script.php dev/build flush=1
You can’t perform that action at this time.