Skip to content

Instantly share code, notes, and snippets.

@gmarik
gmarik / rho.rb
Created November 14, 2010 01:30
crap
# Return the directories where we need to load configuration files
def process_model_dirs(app_manifest_filename=nil)
File.open(app_manifest_filename).each do |line|
str = line.chomp
if str != nil and str.length > 0
#puts "model file: #{str}"
modelName = File.basename(File.dirname(str))
Rhom::RhomObjectFactory.init_object(modelName)
require str
From 6737da2323d9896fe30de66394a659de2b41e9b1 Mon Sep 17 00:00:00 2001
From: gmarik <gmarik@gmail.com>
Date: Tue, 16 Nov 2010 22:05:27 -0600
Subject: [PATCH] Do not set Content-Type header when body defined
---
platform/shared/net/AsyncHttp.cpp | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/platform/shared/net/AsyncHttp.cpp b/platform/shared/net/AsyncHttp.cpp
@gmarik
gmarik / content_types again
Created December 5, 2010 03:03
this doesn't work. Why? because value is a string in a key-value store.
# looks like Content-type is set to application/octet-stream for nil values
#
User-Agent: Mozilla-5.0 (ANDROID; generic; 2.2)
I/APP ( 3006): Content-Length: 3531
I/APP ( 3006): Content-Type: multipart/form-data; boundary=----------------------------44729c969b01
I/APP ( 3006):
I/APP ( 3006): I 12/04/2010 20:55:34:609 0066c790 Net| => Send data (818 bytes): ------------------------------44729c969b01
I/APP ( 3006): Content-Disposition: form-data; name="bill[amount]"
I/APP ( 3006): Content-Type: application/octet-stream
I/APP ( 3006): Content-Length: 0
bills = [
{:name=>"bill[attachment]",
:filename=>"/data/data/com.rhomobile.imageupload/rhodata/apps/rhoconfig.txt"},
{:name=>"bill[amount]",
:body=>nil}]
Rho::AsyncHttp.upload_file(
:url => 'http://localhost:3000/bills.json',
:callback => url_for(:action => :push_callback),
:multipart => bills)
@gmarik
gmarik / expires_fix_2311.rb
Created April 4, 2011 22:13
:expire_after rails 2.3.11 workaround
# workaround for https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6634-railsrack-inconsistency-about-expires_afterexpires-cookie-option#ticket-6634-3
# expiration issue
# drop into RAILS_ROOT/config/initializers/expires_fix_2311.rb
#
require 'rack'
Rack::Utils.class_eval do
class << self
def set_cookie_with_expire!(header, key, value)
if value[:expires].blank? && value[:expire_after]
@gmarik
gmarik / c-xc-s.vim
Created April 14, 2011 04:08
vim-starter-kit
nnoremap <silent> <special> <C-x><C-s> :if expand("%") == ""<Bar>browse confirm update<Bar> else<Bar>confirm update<Bar>endif<CR>
vmap <special> <C-x><C-s> <Esc><D-s>gv
imap <special> <C-x><C-s> <C-O><D-s>
cmap <special> <C-x><C-s> <C-C><D-s>
omap <special> <C-x><C-s> <Esc><D-s>
syntax on
set nocompatible " Unset compatibility with VI, it's 2011!
set wildmenu
set wildmode=list:longest " make cmdline tab completion similar to bash
set backup " Activate backup stuff
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set showmatch " Show matching brackets

What's new

Bundle! command

Bundle! 'my_plugin'

instructs Vundle that

  1. this plugin should not be synchronized/cloned
  2. it's located in bundles/my_plugin

Getting started

First add your twitter username and password. Then server.rb and once it's started open websocket.html in your browser. You should see some tweets appear. If not take a look at the javascript console.

@gmarik
gmarik / game_of_life.rb
Created May 14, 2011 21:31
coderetreat wpg
class Cell
end
class World
def initialize
@x = 50
@y = 50
end