Skip to content

Instantly share code, notes, and snippets.

View pcg79's full-sized avatar

Pat George pcg79

  • FreeAgent
  • Edinburgh, Scotland
View GitHub Profile
@pcg79
pcg79 / music.yml
Created September 26, 2014 18:37
Yaml file for music
genres:
- name: Classic Rock
artists:
- name: Led Zeppelin
albums:
- name: I
tracks:
- name: Babe, I'm Gonna Leave You
- name: Black Mountain Side
- name: Communication Breakdown
@pcg79
pcg79 / gist:b209935eb1b1a1de1211
Created April 30, 2014 00:25
Marvel character api result
{
"id" => 1009521,
"name" => " Hank Pym",
"comics" => {
"available" => 44,
"collectionURI" => "http://gateway.marvel.com/v1/public/characters/1009521/comics",
"items" => [
[ 0] {
"resourceURI" => "http://gateway.marvel.com/v1/public/comics/35533",
"name" => "Amazing Spider-Man (1999) #661"
@pcg79
pcg79 / pe12.py
Last active August 29, 2015 13:56
def factors(n):
count = 0
for i in range(1, n):
if n % i == 0:
count = count + 1
if count >= 500
return true
@pcg79
pcg79 / pj1.rb
Created November 21, 2013 14:55
Project Euler #1
sum = 0
1000.times do |x|
sum += x if x % 3 == 0 || x % 5 == 0
end
puts sum
#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)
@pcg79
pcg79 / .autotest
Created July 20, 2011 15:11
.autotest for ignoring solr
Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store ._* vendor tmp log doc solr}.each do |exception|
autotest.add_exception(exception)
end
end
class Rating < ActiveRecord::Base
belongs_to :user
belongs_to :rater, :class_name => 'User', :foreign_key => 'rater_id'
belongs_to :account
attr_accessible :score, :rater_id, :user_id, :rater, :user
VALID_SCORES = 1..3
validates_presence_of :score, :user_id, :rater_id, :account_id
@pcg79
pcg79 / gist:738210
Created December 12, 2010 17:55
Raw HTML of Interstitial page
<p id="redirect_to">You will be redirected to the following URL in 5 seconds: <a id="redirect_url" href="<your link's url>"><Your link's url></a></p>
@pcg79
pcg79 / gist:738207
Created December 12, 2010 17:49
Using jQuery to manipulate Interstitial page
<script type="text/javascript">
$(document).ready(function() {
var href = $("#redirect_url")[0].href;
$("a#replace_me").attr("href", href);
$("a#replace_me").text(href);
$("#redirect_to").hide();
});
</script>
<p>Greetings. We are now redirecting you to the site that you requested.</p>