Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@bsodmike
bsodmike / model.rb
Created July 8, 2011 21:44 — forked from jonpaul/model.rb
validates is_good
validate :is_valid_time
def valid_time?
self.time > 24.hours.from_now
end
def is_valid_time
errors.add("Your object", "is not valid. Other explainations.") unless valid_time?
end
@bsodmike
bsodmike / .watchr
Created July 8, 2011 21:57 — forked from ogredude/.watchr
My .watchr with red/green and Growl support
# Run me with:
#
# $ watchr .watchr
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def growl(result)
result_lines = result.split("\n")
  • Picture/File Archive on the admin site

  • Ability to upload files + file archive

  • Opportunity for bold, italic and underlined on news titles - An inline editor like tinyMCE (daniel)

  • Same system on program pages as the news page - image, text and read more when you reach over 120 + characters merge with text 2, where we could write a minimum of 3 lines. + Link under each performance: Info on ticket sales

  • More events at. day on the calendar - possibly.

  • Link by each event in the calendar - in admin module where you can choose for a page on the site, which should be linked on to

@bsodmike
bsodmike / markup.html
Created July 27, 2011 14:27
For Jamie
<div id="subcontent-wrapper">
<div id="section-wrap">
<div id="sidebar-left" style="float: left; width: 239px; padding: 0px; height: 600px; ">
SIDE BAR LEFT BOOOYEAH!
</div>
<div id="sidebar-right">
BOOO
</div>
@bsodmike
bsodmike / development.rb
Created August 29, 2011 08:14 — forked from MyArtChannel/development.rb
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@bsodmike
bsodmike / gist:1184632
Created August 31, 2011 20:29
Git Workflow for Working with Shared Branches
#Workflow
git co development
git pull
git co -b todays_work // create new temp working branch
...do some work...
git commit
git co development
git pull ----- (remote changes come in)
### inspect all changes ###
git co todays_work
@bsodmike
bsodmike / gist:1186379
Created September 1, 2011 15:12
SOP Failing Yahoo stock quotes via AJAX
<!doctype html>
<html>
<head>
</head>
<body>
<h2>result</h2>
<div class="result"></div>
<h2>result2</h2>
@bsodmike
bsodmike / ystock.rb
Created September 1, 2011 15:23
ystock gem source
#
# Yahoo Stock find
# gem ystock
#
# by Greg Winn
# winn.ws
# http://github.com/gregwinn/ystock
#
require 'cgi'
require 'net/http'
@bsodmike
bsodmike / resque_auth.md
Created September 1, 2011 22:42
Hardened 'resque_auth.rb' Initialiser

Here's how I hardened the login via resque_auth.rb. You'll need the bcrypt-ruby gem installed.

  • Fire up IRB or PRY
  • require 'bcrypt'
  • Generate a salt: salt = BCrypt::Engine.generate_salt
  • puts salt // make sure you copy this somewhere.
  • Now, salted_hash = BCrypt::Engine.hash_secret("YOUR PASSWORD GOES HERE", salt)
  • make sure you save the longer output!

Update resque_auth.rb as follows - it limits access to the username 'admin' as well!

@bsodmike
bsodmike / application_helper.rb
Created September 5, 2011 10:24
Helper method to safely sanitise text with RedCloth
module ApplicationHelper
def redcloth_sanitize(text)
# http://www.jeffroush.com/technotes/2011/01/02/using-textile-in-rails/
sanitize(RedCloth.new(text, [:filter_html, :filter_styles]).to_html)
end
end