Skip to content

Instantly share code, notes, and snippets.

View markahesketh's full-sized avatar
🚀

Mark Hesketh markahesketh

🚀
View GitHub Profile
location / {
index index.php;
# serve static files directly
if (-f $request_filename) {
access_log off;
expires 30d;
break;
}
# rewrite from example.com to www.example.com
server {
listen 80;
server_name example.com;
rewrite ^(.+?)/?$ http://www.example.com$1 permanent;
}
server {
listen 80;
server_name www.example.com;
!Loop
Assistant.Macros.IfAction|50|1|1|Wool
Assistant.Macros.DoubleClickTypeAction|3576|True
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.AbsoluteTargetAction|0|0|1079887630|1373|2597|7|4117
Assistant.Macros.PauseAction|00:00:00.8000000
Assistant.Macros.IfAction|50|1|1|Wool
Assistant.Macros.DoubleClickTypeAction|3576|True
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.AbsoluteTargetAction|0|0|1079888023|1373|2598|7|4117
<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>
# /app/models/product.rb
validates :title, :uniqueness => true,
:length => {:minimum => 10,
:message => 'Title is too short. Must be at least 10 characters'}
# /test/unit/product_test.rb
test "product title must be at least 10 characters long" do
product = Product.new(:description => "yyy",
:price => 1,
:image_url => "fred.gif")
# /app/models/product.rb
validates :title, :description, :image_url, :presence => true
validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
validates :title, :uniqueness => true,
:length => {:minimum => minimum = 10,
:message => "is too short. Must be at least #{minimum} characters."}
validates :image_url, :format => {:with => %r{\.(gif|jpg|png)$}i,
:message => 'must be a URL for GIF, JPG, or PNG image.'
}
# /app/controllers/store_controller.rb
class StoreController < ApplicationController
def index
@products = Product.all
session[:counter] ||= 0
@count = session[:counter] += 1
end
end
St Totteringham's Day
Happy St. Totteringham's day.
This being the season with the best Spurs team in years, and the worst Arsenal team in years, we congratulate Arsene Wenger on this achievement.
We apologise, however, for the late arrival of St. Totteringhams day this year, and assure you normal service will be resumed next season.
Regards,
Gav, exiled Gooner, Melbourne
<data>
<products-by-instances>
<entry id="1975">
<name>Sample Name</name>
<brand>
<item id="1970">Sample Brand</item>
</brand>
<instances>
<item id="1972">MILT501</item>
<item id="1974">MILT502</item>
<data>
<portfolio-collaborations>
<section id="2" handle="collaborations">Collaborations</section>
<entry id="454">
<title handle="test-collaboration">Test collaboration</title>
<images>
<item>
<file size="75 KB" path="/img/collaborations" type="image/jpeg">
<filename>Agate-Necklace-by-The-Vamoose-001.jpg</filename>
</file>