Skip to content

Instantly share code, notes, and snippets.

View myobie's full-sized avatar

Nathan myobie

View GitHub Profile
# 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)
>> 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
@myobie
myobie / gist:49759
Created January 21, 2009 00:03 — forked from eltiare/gist:49680
chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
str = (1..50).map { chars[rand(chars.size)] }.join
# 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/]
## 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
## 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
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
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)
# 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
layout do
%Q{
!!!
%html
%head
%title nathanherald.com
%body
= yield
}.margin
end