This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Our Site | |
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0 | |
Connection close | |
Content-Type text/html; charset=UTF-8 | |
Date Thu, 15 Jan 2009 03:34:50 GMT | |
Expires Mon, 26 Jul 1997 05:00:00 GMT | |
Last-Modified Thu, 15 Jan 2009 03:34:51 GMT | |
Pragma no-cache | |
Server Apache/2.2.3 (CentOS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> Review.detect?("Rating: 4\nItem: Dyson\n\nThis should be the description.") | |
=> true | |
>> Chat.detect?("You: Hello\nMe: Hello back at ya!\nYou: Wanna go eat\nYou: Somehwere\nMe: Yes!") | |
=> true | |
>> Chat.detect?("Rating: 4\nItem: Dyson\n\nThis should be the description.") | |
=> false | |
>> Review.detect?("You: Hello\nMe: Hello back at ya!\nYou: Wanna go eat\nYou: Somehwere\nMe: Yes!") | |
=> false | |
# The code that makes this work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a | |
str = (1..50).map { chars[rand(chars.size)] }.join |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hitting the homepage with cleared cookies: | |
Processing DocumentsController#home (for 71.191.200.199 at 2009-02-05 19:10:13) [GET] | |
Parameters: {"action"=>"home", "controller"=>"documents"} | |
$$ Logging the session to yaml: | |
--- !map:ActionController::Session::AbstractStore::SessionHash | |
:session_id: 4446f990e6c514e5d045b903761449e0 | |
Rendering template within layouts/application | |
Rendering documents/home | |
Completed in 16ms (View: 4, DB: 0) | 200 OK [http://208.78.102.202/] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In my controller | |
def test_set | |
session[:test_value] = 'This should exist.' | |
redirect_to '/test_get' | |
end | |
def test_get | |
@value = session[:test_value] | |
session[:test_value] = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Sessions/create | |
class SessionController | |
def create | |
logout_keeping_session! | |
user = User.authenticate(params[:login], params[:password]) | |
if user | |
# Protects against session fixation attacks, causes request forgery | |
# protection if user resubmits an earlier form using back | |
# button. Uncomment if you understand the tradeoffs. | |
# reset_session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReferenceError: Error #1069: Property servicesXML not found on com.themessagecenter.controlpanel.view.ResellerGrid and there is no default value. | |
at com.themessagecenter.controlpanel.view::ProvisionNavGrid/_init()[/Users/nathan/Documents/Flex Builder 3/TMC Control Panel/src/com/themessagecenter/controlpanel/view/ProvisionNavGrid.mxml:25] | |
at com.themessagecenter.controlpanel.view::ProvisionNavGrid/___ProvisionNavGrid_DataGrid1_creationComplete()[/Users/nathan/Documents/Flex Builder 3/TMC Control Panel/src/com/themessagecenter/controlpanel/view/ProvisionNavGrid.mxml:16] | |
at flash.events::EventDispatcher/dispatchEventFunction() | |
at flash.events::EventDispatcher/dispatchEvent() | |
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298] | |
at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169] | |
at mx.managers::LayoutManager/validateClient()[C:\autobuild\3.2.0\frameworks\projec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Namespace | |
# Load file into module/class namespace. | |
def module_load(path) | |
if path =~ /^[\/~.]/ | |
file = File.expand_path(path) | |
else | |
$LOAD_PATH.each do |lp| | |
file = File.join(lp,path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extend String so we can keep our haml indented properly | |
class String | |
def indents | |
n = match(/^(\s+)/) | |
n = n.nil? ? 0 : n.captures.first.length | |
gsub(/^\s{0,#{n}}/, "") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layout do | |
%Q{ | |
!!! | |
%html | |
%head | |
%title nathanherald.com | |
%body | |
= yield | |
}.margin | |
end |