Skip to content

Instantly share code, notes, and snippets.

--- a/app/views/layouts/_home_link.rhtml
+++ b/app/views/layouts/_home_link.rhtml
@@ -1,5 +1,5 @@
<!-- ========= ITEM ========= -->
-<div class="item" onClick="document.location='<%= home_link[:url] %>'">
+<div class="item" onClick="this.setAttribute('onclick', 'return false;'); document.location='<%= home_link[:url] %>'">
<a href="<%= home_link[:url] %>"><div class="icon"
style="background-position: <%= home_link[:icon_pos][:x] %>px <%= home_link[:icon_pos][:y] %>px">&nbsp;</div></a>
<div class="label"><a href="<%= home_link[:url] %>"><%= home_link[:label] %></a>
diff --git a/app/views/layouts/_nav_link.rhtml b/app/views/layouts/_nav_link.rhtml
@ewpeters
ewpeters / gist:3364575
Created August 15, 2012 23:13
Fizz Buzz Face Off
require 'benchmark'
class FizzBuzz
def fizz m
m % 5 == 0 ? "Fizz" : nil
end
def buzz n
n % 3 == 0 ? "Buzz" : nil
end
#!/usr/bin/env script/runner
# This file is used to import a dump of ODOC im
destinations = []
Identity::Manuals.find_in_batches(:conditions => "what_system_did_i_come_from = 5") do |batch|
batch.each do |identity_manual|
destinations << [identity_manual.destination_id, identity_manual.facility_id]
identity_manual.delete
end
def crypt_unless_empty
if password.blank?
self.password = self.password_was
elsif ! nocrypt && self.password_changed?
write_attribute "password", self.class.sha1(password)
end
end
<script type="text/javascript">
$(document).ready(function(){
alert("<%=controller.controller_name%>")
});
</script>
Dungeon Crawl Stone Soup version 0.10.0 character file.
Erik the Acrobat (Kobold Berserker) Turns: 128024, Time: 07:15:29
HP 179/179 AC 27 Str 26 XL: 27
MP 22/22 EV 36 Int 11 God: Trog [******]
Gold 4424 SH 15 Dex 23 Spells: 0 memorised, 26 levels left
Res.Fire : + . . See Invis. : + a - +5,+9 quick blade {god gift}
Res.Cold : . . . Warding : . . X - +8 ring mail of Bumone {rElec}
Dungeon Crawl Stone Soup version 0.10.0 character file.
Erik the Swashbuckler (Kobold Berserker) Turns: 79787, Time: 04:21:02
HP 116/116 (120) AC 26 Str 26 XL: 19 Next: 53%
MP 18/18 EV 31 Int 12 God: Trog [*****.]
Gold 2391 SH 13 Dex 19 Spells: 0 memorised, 18 levels left
Res.Fire : + . . See Invis. : + a - +5,+9 quick blade {god gift}
Res.Cold : . . . Warding : . . X - +8 ring mail of Bumone {rElec}
@ewpeters
ewpeters / gist:1240286
Created September 25, 2011 05:58
It's a table flip
(╯°□°)╯︵ ┻━┻
def is_eager_loaded?(model, association)
!model.instance_variable_get("@#{association.to_s}").nil?
end
user = User.find(1, :include => :haunts)
is_eager_loaded?(user, :haunts)