Skip to content

Instantly share code, notes, and snippets.

View jimsynz's full-sized avatar
💜

James Harton jimsynz

💜
View GitHub Profile
@jimsynz
jimsynz / user.rb
Created December 19, 2011 22:44
WTF!
class User
include Mongoid::Document
field :email
validates_format_of :email, :with => /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i, :message => "is not a valid email adress."
end
@jimsynz
jimsynz / index.html
Created December 20, 2011 21:49
Attempting to convert ember.js' index.html to haml
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
@jimsynz
jimsynz / gist:1507992
Created December 21, 2011 22:22
rubygems.org failure
[11:15][jnh@Marjory]~/Dev/forks/emberjs-rails$ gem push emberjs-rails-0.1.0.gem
Pushing gem to https://rubygems.org...
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
Kimono = Ember.Application.create()
window.Kimono = Kimono
header = Ember.View.create
logoUri: "<%= image_path('kimono-vsmall-notext.png') %>"
templateName: 'views_header'
isVisible: false
elementId: 'header'
header.appendTo('#layout')
~$ cd HelloWorld
~/HelloWorld$ echo "gem 'emberjs-rails'" >> Gemfile
~/HelloWorld$ bundle
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using multi_json (1.0.4)
Using activesupport (3.1.3)
Using builder (3.0.0)
Using i18n (0.6.0)
@jimsynz
jimsynz / faye-rails-client-spec.rb
Created January 1, 2012 19:35
For the life of me I can't make this work...
shared_examples_for "a Faye server" do
self.use_transactional_fixtures = false
it "should have Event Machine reactor running" do
EM.reactor_running?.should be_true
end # Passes.
it "should be able to subscribe to channel" do
channel = "/random/#{rand(65534).to_s}"
message = "Successful subscription."
@jimsynz
jimsynz / sync_rack_adapter.rb
Created January 3, 2012 08:29
attempting to create a fiber based queue.
def handle_request(request)
json_msg = message_from_request(request)
message = JSON.parse(json_msg)
jsonp = request.params['jsonp'] || JSONP_CALLBACK
headers = request.get? ? TYPE_SCRIPT.dup : TYPE_JSON.dup
origin = request.env['HTTP_ORIGIN']
debug 'Received ?: ?', request.env['REQUEST_METHOD'], json_msg
@server.flush_connection(message) if request.get?
class TokenExtension
def incoming(m,c)
if m['channel'] == '/service/requestToken'
token = if m['ext'] && m['ext']['token']
Token.find_by_token(m['ext']['token'])
elsif by_client = Token.find_by_client_id(m['clientId'])
by_client
else
Token.new.tap { |t| t.client_id = m['clientId'] }
end
@jimsynz
jimsynz / errors.txt
Created February 28, 2012 22:58
grammar
1.9.3-p0 :002 > Crimson::Parser.parse('nil')
Exception: Parse error: Expected one of -, 0, nil at line 1, column 4 (byte 4) after .
from /Users/jnh/Dev/Toys/CrimsonScript/lib/crimson/parser.rb:12:in `parse'
from (irb):2
from /Users/jnh/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
1.9.3-p0 :003 > Crimson::Parser.parse('0')
Exception: Parse error: Expected one of -, 0, nil at line 1, column 2 (byte 2) after .
from /Users/jnh/Dev/Toys/CrimsonScript/lib/crimson/parser.rb:12:in `parse'
from (irb):3
from /Users/jnh/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
" Function which runs a command using ConqueTerm in the
" current or split buffer.
" If no command is given it just runs bash.
function! RunCommandInBuffer(where,...)
" Can split the buffer if you want.
if a:where == 'new'
exec ':new'
elseif a:where == 'vnew'
exec ':vnew'
end