Skip to content

Instantly share code, notes, and snippets.

View hale's full-sized avatar

Philip Hale hale

View GitHub Profile
@hale
hale / notes.md
Last active August 29, 2015 14:01

Contact Manager: Notes

Rails 4.0.4

  • There's some compatibility issues between Rails 4.1 and PgSearch which I might use for steps 2-3, so sticking with 4.0.4.

Validations

  • Does not validate against whitespace-only fields or fields beginning with whitespace.
@hale
hale / test.rb
Created September 23, 2014 17:58
module Security
module Bouncer
THE_LIST = %w(john)
def enter(name)
raise "Sorry #{name}, you're not on the list" unless THE_LIST.include?(name)
puts "Hey #{name}, come on through."
super(name)
end
end
@hale
hale / test.rb
Created September 23, 2014 18:05
class NotOnTheListError < StandardError; end
module Security
module Bouncer
THE_LIST = %w(john disco_stu)
def enter(name)
unless THE_LIST.include?(name)
raise NotOnTheListError.new("Sorry #{name}, you're not on the list")
end
<?PHP
error_reporting(0);
$con = mysql_connect("trogon.csd.abdn.ac.uk","wtstudent","DyNEDurA");
mysql_select_db("webtech", $con);
$result = mysql_query("SELECT * FROM chart");
?>
<p>
<?PHP
while($row = mysql_fetch_array($result)) {
echo $row['Artist'] . " - ". $row['Title'] . "<br />";
@hale
hale / gist:964452
Created May 10, 2011 13:18
debian 6 cherokee error log
root@vps:/# apt-get install cherokee
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
file libcherokee-base0 libcherokee-client0 libcherokee-config0 libcherokee-mod-admin libcherokee-server0 libexpat1 libmagic1 libmysqlclient16 mime-support mysql-common python
python-minimal python-support python2.6 python2.6-minimal spawn-fcgi
Suggested packages:
cherokee-doc libcherokee-mod-geoip libcherokee-mod-ldap libcherokee-mod-libssl libcherokee-mod-mysql libcherokee-mod-rrd libcherokee-mod-streaming python-doc python-tk
python-profiler python2.6-doc python2.6-profiler binutils binfmt-support
http://www.cherokee-project.com/benchmarks.html
http://www.rkblog.rk.edu.pl/w/p/lighttpd-and-cherokee-benchmark/
http://www.rkblog.rk.edu.pl/w/p/pylons-benchmark-various-servers/
@hale
hale / HailstoneLengthQuick.java
Created October 9, 2011 23:35
HailstoneLengthQuick
public class HailstoneLengthQuick {
public static void main(String[] args) {
int max = 0;
int lower = Integer.parseInt(args[0]);
int upper = Integer.parseInt(args[1]);
for (long n = upper; n >= lower; n--) {
long workingN = n;
int count = 2;
while (workingN!=2) {
count++;
@hale
hale / Main.java
Created October 10, 2011 01:12
sanna3n
/**
* Main class
* @author Susanna Kempe
* @version 10th October 2011
*/
public class Main {
/**
* @param args the command line arguments
*/
@hale
hale / ClimbSort.java
Created November 8, 2011 19:04
ClimbSort
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class ClimbSort {
public static void main(String[] args) throws IOException{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> output = new ArrayList<String>();
int numberOfTestCases = Integer.parseInt(input.readLine());
@hale
hale / MyFamily.java
Created November 10, 2011 22:35
MyFamily
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
* CS2011 Homework, Codemarker, 'My Family'
* User: Philip Hale
* ID: 50907446
* Date: 10/11/11