Skip to content

Instantly share code, notes, and snippets.

View appsol's full-sized avatar

Stuart Laverick appsol

View GitHub Profile
class daughter extends parent implements teenager {
public $attitude;
private $moods = array('happy', 'angry', 'sulky', 'upset', 'silly', 'grumpy');
public function __construct() {
$this->attitude = $this->moods[array_rand($moods)];
$this->wakeup(time());
}
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<!-- ############# GLOBAL LAYOUT UPDATES ############# -->
<default>
<!-- Remove unwanted blocks entirely
<remove name="right.poll"/>
<remove name="right.permanent.callout"/>
@appsol
appsol / gist:95e258d7b1b70d71b15d
Last active August 29, 2015 14:01
Saasbook Project 3.5
#!/usr/bin/env ruby
# Project 3.5
class Time
def at_beginning_of_year
self.class.local self.year
end
end
class Fixnum
@appsol
appsol / gist:f7555786d620ca274c63
Last active August 29, 2015 14:01
Saasbook Project 3.2
#!/usr/bin/env ruby
# Project 3.2
# Print an objects class and it's ancestors up to BasicObject
def class_print(o)
c = o.class
until c.nil? do
puts c
c = c.superclass
end
@appsol
appsol / gist:ca372d9ba1bbbf3996e4
Created May 25, 2014 10:18
Saasbook Project 3.7
#!/usr/bin/env ruby
# Project 3.7
module Enumerable
def each_with_custom_index (start, step)
index = start
self.each do |x|
yield x, index
index+= step
@appsol
appsol / gist:e410ca10c6f1890de60d
Created May 25, 2014 10:21
Saasbook Project 3.7
#!/usr/bin/env ruby
# Project 3.7
class FibSequence
include Enumerable
def initialize(n)
@max = n
@x = 0
@y = 1
@appsol
appsol / gist:76dfdefbaef0091e6fe8
Created May 25, 2014 10:42
Saasbook Project 3.9
#!/usr/bin/env ruby
# Project 3.9
module Enumerable
def each_with_flattening
flattened = self.flatten
flattened.each do |x|
yield x
end
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@appsol
appsol / gist:d7b2af6d053c4151b4b1
Created September 11, 2014 09:48
Vagrant up ssh error
groups="/"
ostype="Red Hat (64 bit)"
UUID="37ee2d6c-3883-40d7-a1aa-62d3319d7c7f"
CfgFile="/home/stuart/VirtualBox VMs/teamwildoutfitters.com/teamwildoutfitters.com.vbox"
SnapFldr="/home/stuart/VirtualBox VMs/teamwildoutfitters.com/Snapshots"
LogFldr="/home/stuart/VirtualBox VMs/teamwildoutfitters.com/Logs"
hardwareuuid="37ee2d6c-3883-40d7-a1aa-62d3319d7c7f"
memory=1024
pagefusion="off"
vram=8
@appsol
appsol / README.md
Last active August 29, 2015 14:16 — forked from dciccale/README.md

DOM Ready

Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.