Skip to content

Instantly share code, notes, and snippets.

View pyrmont's full-sized avatar

Michael Camilleri pyrmont

View GitHub Profile
@pyrmont
pyrmont / proof.txt
Last active December 14, 2015 02:39
The premise leads to a contradiction. The only conclusion is that the premise is false.
Premise
- consider X, a non-zero integer with n digits;
- consider Y, a non-zero integer that is formed by moving the first digit from X to the position of the last digit and shifting all of the remaining digits one place to their immediate left;
- there is a value for X such that, when doubled, equals Y.
Axioms
- when you double an integer, you multiply each of its digits by 2;
- the product of each digit being multipled by 2 may be incremented by 1 if the digit to its immediate right was 5 or more.
@pyrmont
pyrmont / router.php
Created May 7, 2013 06:43
Routing file for PHP's built-in web server to work on WordPress (and serve PDFs).
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
if(file_exists($root.$path)) {
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') {
@pyrmont
pyrmont / localist.php
Last active December 17, 2015 04:58
Initial version of a plugin to ease local development of WordPress websites.
<?php
/*
Plugin Name: Localist
Plugin URI:
Description: Localist allows you to reach an installation of WordPress regardless of the WordPress address defined in the database.
Version: 1.0
Author: Michael Camilleri
Author URI: http://inqk.net/
License: Public Domain
*/
@pyrmont
pyrmont / deploy.rb
Created August 7, 2013 06:47
Capistrano recipe for the 2014 staff recruitment page.
default_run_options[:pty] = true # Must be set for the password prompt from git to work
set :ssh_options, { :forward_agent => true }
set :user, "smash"
set :application, "SMASH! Join Us"
set :domain, "linode.smash.org.au"
set :repository, "file://."
set :deploy_to, "/var/www/smash.org.au/2014-staff-call"
set :shared_path, "#{deploy_to}/shared"
set :use_sudo, false
@pyrmont
pyrmont / nginx.conf
Last active December 21, 2015 17:49
Basic Nginx configuration file.
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/etc/nginx/mime.types; # Update if necessary
@pyrmont
pyrmont / nginx.conf
Created August 26, 2013 15:40
This configuration file is designed to run the CMS Koken. If you just want a simple config file, use this instead: https://gist.github.com/pyrmont/6342859
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/etc/nginx/mime.types; # Update if necessary
@pyrmont
pyrmont / keybase.md
Created May 29, 2014 05:28
Public proof of my identity for Keybase.

Keybase proof

I hereby claim:

  • I am pyrmont on github.
  • I am pyrmont (https://keybase.io/pyrmont) on keybase.
  • I have a public key whose fingerprint is 48CB 53C1 4452 A166 43C0 C90E 871B 359F 2AC9 F4F0

To claim this, I am signing this object:

@pyrmont
pyrmont / ruby_first.md
Created June 10, 2014 05:54
Ruby as a First Programming Language

My friend Rob tweets:

The more experience I get with Ruby, the more irresponsible I feel when teaching it to new devs.

OK, so I think Ruby is a good language to use to start teaching programming for a number of reasons.

First, I believe it's best to start beginners with an object-oriented language. The OO paradigm provides, in my opinion, the best balance between power and comprehensibility. I'm happy to concede that OO languages do not immediately make sense to a lot of people in a way that procedural languages do. After all, if you can read a recipe, you can basically read procedural code. The problem is that it's pretty difficult to do anything interesting in procedural languages and doing interesting things is what will motivate a person to get past their early, and inevitable, frustration. You might accept this but argue that functional languages have a high degree of power and should be the starting point. Unfortunately, while functional

@pyrmont
pyrmont / shout.service
Last active August 29, 2015 14:06
An example of a systemd service file for Shout.
[Unit]
Description=Node.js process for Shout
[Service]
ExecStart=/usr/bin/shout
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=shout-irc
User=shout-irc
@pyrmont
pyrmont / pattern-matching-syntax-examples.rb
Created September 8, 2018 16:54
Pattern Matching Syntax Examples
# Current
case obj
when String
"String"
else
"Other"
end
# Deconstructing
case obj