Skip to content

Instantly share code, notes, and snippets.

View paulgroves's full-sized avatar

Paul Groves paulgroves

View GitHub Profile
@paulgroves
paulgroves / CoffeeScript.sublime-settings
Last active February 22, 2016 09:35
Sublime sync setting
{
"extensions":
[
"coffee"
]
}

Keybase proof

I hereby claim:

  • I am paulgroves on github.
  • I am paulgroves (https://keybase.io/paulgroves) on keybase.
  • I have a public key ASAvOnEovSvNfmtEC0RaW1aIxx_BQ42uabV-xTgkiWDt3wo

To claim this, I am signing this object:

@paulgroves
paulgroves / clock.rb
Last active November 3, 2015 09:10
Calculate angles between clock hands
class Clock
DEGREES = 360.0
MINUTES = 60.0
HOURS = 12.0
attr_accessor :hour, :minute
def initialize(hour:, minute:)
validate_inputs!(hour, minute)
# If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
class MulitpleSum
attr_reader :target, :dividers
def initialize(target:, dividers:[])
@target = target
module RoleAuthentication
extend ActiveSupport::Concern
included do
append_before_filter :authorize_action
end
module ClassMethods
[:allow, :deny].each do |auth_action|
@paulgroves
paulgroves / podcast-categories.rb
Created November 16, 2014 10:48
Apple Podcast Categories
{ "Arts" => ["Design", "Fashion & Beauty", "Food", "Literature", "Performing Arts", "Visual Arts"],
"Business" => ["Business", "Business News", "Careers", "Investing", "Management & Marketing", "Shopping"],
"Comedy" => [],
"Education" => ["Education", "Education Technology", "Higher Education", "K-12 (School)", "Language Courses", "Training"],
"Games & Hobbies" => ["Automotive", "Aviation", "Hobbies", "Other Games", "Video Games"],
"Government & Organisations" => ["Local", "National", "Non-Profit", "Regional"],
"Health" => ["Alternative Health", "Fitness & Nutrition", "Self-Help", "Sexuality"],
"Kids & Family" => [],
"Music" => [],
"News & Politics" => [],
@paulgroves
paulgroves / prevent_widows.coffee
Last active December 31, 2015 00:38
Coffeescript to prevent widows in title elements, can cope with nested HTML such as a or span elements
jQuery.fn.justtext = ->
$(this).clone().children().remove().end().text()
prevent_widows = () ->
$("h1,h2,h3,h4,h5,h6").each (i, e) =>
t = $.trim($(e).justtext()).replace(/\s([^\s]*)$/,'\xa0'+'$1')
cache = $(e).children()
$(e).text(t).append cache
$(e).find('*').each (i, e) =>
t = $.trim($(e).justtext()).replace(/\s([^\s]*)$/,'\xa0'+'$1')
@paulgroves
paulgroves / uoe_colours.scss
Created May 24, 2012 16:51
University of Essex - corporate colour palette
$powder_blue: #9ec3de;
$turquoise: #00afd8;
$cornflower: #0065bd;
$royal_blue: #002f57;
$dark_purple: #4b306a;
$aqua: #72b5cc;
$mint: #35c4b5;
$seagrass: #007a87;
$bluebell: #4c5cc5;
$violet: #622567;
@paulgroves
paulgroves / rewrite.script
Created March 31, 2012 10:07
Textpattern rewrite rules for Zeus webserver
# Zeus webserver version of basic Textpattern mod_rewrite rules
map path into SCRATCH:path from %{URL}
look for file at %{SCRATCH:path}
if exists then goto END
look for dir at %{SCRATCH:path}
if exists then goto END
# Do not apply to admin section i.e /textpattern
match URL into $ with ^/textpattern.*$
if matched then goto END
match URL into $ with ^/css.php?.*$
## about (plain_text)
For more features you might like to try ck_fu plugin - http://r38y.github.com/ck_fu/
## config/deploy.rb
task :build_info do
unix_user = `whoami`.strip
run "echo 'Version #{current_revision} deployed by #{unix_user} at #{Time.now}' > #{current_path}/lib/BUILD_INFO"
end