Skip to content

Instantly share code, notes, and snippets.

View jrnickell's full-sized avatar

John Nickell jrnickell

View GitHub Profile
@jrnickell
jrnickell / serve-static
Last active February 13, 2019 00:36
Docker Python HTTP Server
#!/usr/bin/env bash
# place in ~/bin or a PATH directory
#
# usage:
#
# $ cd /path/to/site
# $ serve-static 8443
#
# port number defaults to 8000
@jrnickell
jrnickell / provision.sh
Created April 9, 2015 23:39
Nginx & PHP-FPM
#!/usr/bin/env bash
# bin folder
cd ~
mkdir -p ~/bin
# base apps and upgrade
sudo apt-get update
sudo apt-get install -y aptitude curl vim git unzip openssl
sudo aptitude -y safe-upgrade
@jrnickell
jrnickell / create-project
Last active March 24, 2017 13:22
Nginx server config
#!/usr/bin/env bash
function create_index
{
cat <<- __EOF__
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>$PROJECT</title>
@jrnickell
jrnickell / random_compat.php
Last active August 29, 2015 14:17
Random compat
if (!function_exists('random_bytes')) {
function random_bytes($length)
{
$buffer = '';
$valid = false;
if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) {
$buffer = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
if ($buffer) {
$valid = true;
}
@jrnickell
jrnickell / setup-dev.sh
Last active August 29, 2015 14:09
Setup Development Machine
#!/usr/bin/env bash
echo -n "==> Choose a password for MySQL and phpMyAdmin: "
read PASSWORD
echo -n "==> Enter your full name for Git configuration: "
read FULLNAME
echo -n "==> Enter your email address for Git configuration: "
read EMAILADD
@jrnickell
jrnickell / permissions.sh
Created May 22, 2014 15:13
Script to apply command-line (user) and apache write permissions to a folder
#!/bin/bash
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1`
sudo setfacl -R -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/storage
sudo setfacl -dR -m u:$APACHEUSER:rwX -m u:`whoami`:rwX app/storage
@jrnickell
jrnickell / Preferences.sublime-settings
Created May 3, 2014 16:18
Sublime Text 2 Settings
{
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
".vagrant",
".idea"
@jrnickell
jrnickell / JohnnyFive.tmTheme
Created January 26, 2014 22:50
My Sublime Text 2 Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
======================================================================
JohnnyFive
======================================================================
A Sublime Text 2 / Textmate theme.
Copyright (c) 2014 John Nickell
Released under the MIT License <http://opensource.org/licenses/MIT>
======================================================================
<?php
class DayCalc
{
protected static $weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
public static function getWeekDay($year, $month, $day)
{
$total = static::getTotalDays($year, $month, $day);
$i = $total % 7;
<?php
class ResourceLocator implements ResourceLocatorInterface
{
protected $defaultMap;
protected $schemes = [];
public function __construct(UriPathMapInterface $defaultMap = null)
{
$this->defaultMap = $defaultMap ?: new UriPathMap();