Skip to content

Instantly share code, notes, and snippets.

View mrichman's full-sized avatar

Mark Richman mrichman

View GitHub Profile
protected void Session_Start(Object sender, EventArgs e)
{
Session["LoggedIn"] = false;
if (!Context.Request.Path.Contains("CreateSession.aspx"))
{
Session.Abandon();
Session.Clear();
Context.Response.StatusCode = 401;
Context.Response.StatusDescription = "Unauthorized";
Context.Response.End();
Scenario: Allow login of a user with valid credentials
Given "hector" a confirmed user with password "supersecret"
When I go to the login page
And I fill in "login" with "hector"
And I fill in "password" with "supersecret"
And I press "Login"
Then I should be logged in
Given /^"(.*)" a confirmed user with password "(.*)"$/ do |name, password|
Given "\"#{name}\" an unconfirmed user with password \"#{password}\""
@mrichman
mrichman / cucumber.rake
Created June 15, 2009 19:21
cucumber.rake
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
begin
require 'cucumber/rake/task'
Cucumber::Rails.bypass_rescue
Cucumber::Rake::Task.new(:features) do |t|
t.fork = true
t.cucumber_opts = %w{--format pretty}
end
task :features => 'db:test:prepare'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html;charset=UTF-8' http-equiv='content-type' />
<title>Edit My Account</title>
<link href="/stylesheets/core.css?1245163223" media="screen" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="/stylesheets/ie.css?1243710337" media="screen" rel="stylesheet" type="text/css" />
<![endif]-->
<script src="/javascripts/jquery-1.3.2.js?1245163665" type="text/javascript"></script>
@mrichman
mrichman / contact_form.rb
Created June 17, 2009 12:01
simple_form errors
class ContactForm < SimpleForm
sender {|c| %{"#{c.name}" <#{c.email}>}}
subject 'Contact Form'
recipients 'markarichman@gmail.com'
append :remote_ip, :user_agent, :session
attribute :name, :validate => true
attribute :email, :validate => defined?(Authlogic::Regex.email) ? Authlogic::Regex.email : /@/
attribute :company_name
attribute :telephone
attribute :message, :validate => true
SELECT c.competition_id, c.Name, c.country_id, c.type, c.seq,
cl.competition_local_id, cl.localized_name, @SiteId AS SiteId
FROM competition c
LEFT JOIN competition_local cl
ON c.competition_id = cl.competition_id
AND cl.site_id = '69C38CB1-AC3C-4F9A-BCA0-27AE315E8A76'
ORDER BY seq
LIMIT 0,10
^~/(?<site_friendlyname>[^?/]+)/manage/(?<entity_type>[^?/]+)/edit/(?<entity_id>[^?/]+)(/?)?$/rosters
~/american/manage/match/edit/36992/rosters
[8:50:01] mark:~ $ sudo port install ruby
Warning: Skipping upgrade since ncursesw 5.7_0 >= ncursesw 5.7_0, even though installed variants "" do not match "+darwin_10". Use 'upgrade --enforce-variants' to switch to the requested variants.
Warning: Skipping upgrade since ncurses 5.7_0 >= ncurses 5.7_0, even though installed variants "" do not match "+darwin_10". Use 'upgrade --enforce-variants' to switch to the requested variants.
Warning: Skipping upgrade since readline 6.0.000_1 >= readline 6.0.000_1, even though installed variants "" do not match "+darwin". Use 'upgrade --enforce-variants' to switch to the requested variants.
---> Computing dependencies for ruby
---> Fetching ruby
---> Attempting to fetch ruby-1.8.7-p174.tar.bz2 from http://www.ibiblio.org/pub/languages/ruby/1.8
---> Attempting to fetch ruby-1.8.7-p174.tar.bz2 from ftp://xyz.lcs.mit.edu/pub/ruby/1.8
---> Verifying checksum(s) for ruby
---> Extracting ruby
@mrichman
mrichman / gist:188750
Created September 17, 2009 21:55
The problem seems to be the haml choice. Same options, but with erb instead, work fine.
[17:53:20] mark:code $ rails lark_template -m http://github.com/ffmike/BigOldRailsTemplate/raw/master/lark_template.rb
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
@mrichman
mrichman / gist:189238
Created September 18, 2009 19:28
This pops up a window, allows the user to select an item, returns that item's id to the parent window, and submits the form on the parent window. Only works in IE & FF, not Safari 4.
<div id="ctl00_c1_vw_Module_Correlations_ep1_pnl1" style="width:60px;text-align:right;display:inline">
<input type="submit"
name="ctl00$c1$vw_Module_Correlations$ep1$b"
value="Add..."
onclick="document.getElementById('ctl00_c1_vw_Module_Correlations_ep1_g_btnDefaultButton').click();return(false);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$c1$vw_Module_Correlations$ep1$b&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))"
id="ctl00_c1_vw_Module_Correlations_ep1_b"
class="i-btn"
style="width:60px;" />
<!-- GetterRobbottoMaster - BEGIN -->