This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Text | |
text/cache-manifest manifest appcache; | |
text/css css; | |
text/html html htm shtml; | |
text/mathml mml; | |
text/plain txt; | |
text/vnd.sun.j2me.app-descriptor jad; | |
text/vnd.wap.wml wml; | |
text/x-component htc; | |
text/x-vcard vcf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
(1..100).each { |n| | |
puts n unless( n%3 == 0 || n%5 == 0) | |
puts 'WAKKA' if (n%3 == 0 && n%5 != 0) | |
puts 'WAAAA' if (n%5 == 0 && n%3 != 0) | |
puts 'WAKKAWAAAA' if (n%3 == 0 && n%5 == 0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As used with CanCan and Devise | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
include ErrorResponseActions | |
rescue_from CanCan::AccessDenied, :with => :authorization_error | |
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found | |
before_filter :authenticate! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"iam:ListInstanceProfiles" | |
], | |
"Sid": "Stmt1381157441000", | |
"Resource": [ | |
"arn:aws:iam::123456789012:instance-profile/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.find_in_batches do |user_batch| | |
do_something_complicated(user_batch) | |
end | |
def do_something_complicated(users) | |
users.each do | |
user.something_complicated | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Could be in lib/tasks/disable_db_tasks_on_production.rake | |
# See original http://www.developingandstuff.com/2014/06/disable-dangerous-rake-tasks-in.html | |
DISABLED_TASKS = [ | |
'db:drop', | |
'db:migrate:reset', | |
'db:schema:load', | |
'db:seed', | |
# ... | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /lib/yourapp/possessive.rb | |
module Yourapp | |
module Possessive | |
# Returns a possessive form of a string | |
def possessive | |
return self if self.empty? | |
self + ('s' == self[-1, 1] ? "'" : "'" + 's') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exercise 01: Show text in a browser</title> | |
</head> | |
<body> | |
<?php | |
// Create a PHP page, with the standard HTML <head>, <title> and <body> tags. | |
// This is not strictly necessary but is good practice and should the first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exercise 04: Creating Arrays</title> | |
</head> | |
<body> | |
<?php | |
// Create array that holds all the provinces of Kenya and output them to the | |
// browser from top to bottom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exercise 05: Manipulating Arrays</title> | |
</head> | |
<body> | |
<?php | |
// Create your array of 30 high temperatures then find the average high | |
// temp, the five warmest high temps and the five coolest high temps. Print |
OlderNewer