Skip to content

Instantly share code, notes, and snippets.

@eric1234
eric1234 / install_phpsh.sh
Created November 5, 2013 19:34
Install phpsh on Ubuntu
# https://gist.github.com/eric1234/7324795
# Make sure git is installed
apt-get install -y git
# Remove functions that phpsh needs from config.
sed -i 's/pcntl_signal,//g' /etc/php5/cli/php.ini
sed -i 's/pcntl_fork,//g' /etc/php5/cli/php.ini
sed -i 's/pcntl_wait,//g' /etc/php5/cli/php.ini
@eric1234
eric1234 / .gitignore
Last active January 24, 2022 15:08
Wordle Starter Words
*.txt
@eric1234
eric1234 / .1 README.md
Last active December 21, 2021 03:41
The Gist-based PHP framework.

Motivation

Writing apps today almost always starts with a framework. Systems such as Ruby on Rails, Django, etc are leading the pack in developing best of breed web frameworks for advanced web apps.

Attempts to copy this style of framework in PHP has largely failed. Systems such as CodeIgniter are buggy and more limited than their counterparts in other languages despite PHP having a much bigger community.

@eric1234
eric1234 / mail.php
Created June 20, 2013 18:51
Helper functions to make it easy to send e-mail in PHP. Allows you to use a PHP file for a template, helps send HTML e-mail and can send via the standard "mail" function or route via the PHP Mail module if available.
<?php
# https://gist.github.com/eric1234/5825514
namespace { // Global namespace
# Inspired by the built-in mail function but much more capable. The only
# deviations from the built-in function interface is:
#
# * $attachments are supported. Pass an array of hashes where the keys
# of the hashes are "path", "name" and "mime_type". attachments are
@eric1234
eric1234 / README.md
Last active April 9, 2021 02:09
Generate non-digest versions of asset files for Rails 4 (similar to the way Rails 3 worked)

Purpose

Restores the generation of non-digest assets from Rails 3. This is essential for when those assets must be referenced outside of Rails. Maybe some of your app in in another language, or maybe some of your JavaScript is dynamically and conditionally loaded.

Usage

Compile your assets with the regular task:

@eric1234
eric1234 / chronic_integration.rb
Last active February 17, 2021 20:20
chronic/ruby/rails integration
# https://gist.github.com/eric1234/3739149
#
# Mass monkey-patching! Provides integration between Chronic, Ruby and
# Rails. So now these all work:
#
# Date.parse "next summer"
# DateTime.parse "in 3 hours"
# Time.parse "3 months ago saturday at 5:00 pm"
#
# In addition we override String#to_date, String#to_datetime, String#to_time.
@eric1234
eric1234 / trello.md
Last active August 7, 2020 21:21
Trello Guidelines

A few quick guidelines on my conventions when using Trello. These are not rules. Trello doesn't enforce a structure allowing each project to adapt to it's needs. But this is a good place to start:

Lists

  • Unquoted - Any card being added to the project which is not in the statement of work and not a bug related to work covered by the statement of work goes here. The goal of this list is to avoid scope creep. If scope is being added we want it to be an explicit decision with an explicit cost estimation. The person creating the card should try to estimate the cost (or get someone to do so for them). The client can then choose to move it to the Todo list if they want to increase the scope. If they choose to hold off for now this list provides an excellent idea source for future rounds of development.
  • Todo - These are tasks that need to be done which are not in active development.
  • In Progress - These are tasks that are actively being worked on by a developer. If you are not actively w
@eric1234
eric1234 / null_pattern.php
Created December 16, 2013 18:23
A null object pattern implemented in PHP
<?php
# Implements a recursive null object pattern.
#
# Implemented as a trait so any object can make it's properties use
# the null pattern without resorting to inheritance.
#
# The goal is so you can pull data off a partially populated object
# without excessive existance checks.
trait NullPattern {
@eric1234
eric1234 / client.rb
Created October 22, 2010 16:35
Will continuously ping a heroku to see if we get any long delays
#!/usr/bin/env ruby
$VERBOSE = true
require 'net/http'
require 'benchmark'
loop do
delay = Benchmark.realtime do
message = Net::HTTP.get('delay.heroku.com', '/') rescue nil
puts "Instead of ping got: #{message}" unless message == "ping\n"
@eric1234
eric1234 / auth.php
Last active September 21, 2019 14:53
A authentication library that provides a login and forgot password function.
<?php
# https://gist.github.com/eric1234/1887174
/*
A PHP library that provides everything necessary for implementing
a login system. You need to create a few files for this to work:
* login.php
* logout.php
* password_reset.php