Skip to content

Instantly share code, notes, and snippets.

@chumpy
chumpy / QueueRPCRequests.markdown
Created January 28, 2012 23:28
Queue RPC requests in GWT

Queue RPC Requests in GWT

The Problem

One of the handier tools in the GWT toolbox is a built in AJAX framework referred to as RPC or Remote Procedure Calls. Here’s the thing: Internet Explorer version 7 and prior is not awesome. IE pre-8 restricts the number of simultaneous XmlHttp requests to two for a given host. In most cases, this restriction doesn’t pose a real problem. For a rich client application (like the kind GWT is a good choice for) that may be leaving one of those two allowable connections open for a long poll while

@chumpy
chumpy / UserAgentUtilsClient.java
Created January 29, 2012 00:02
Using user-agent-utils
UserAgent userAgent = UserAgent.parseUserAgentString((String)request.getHeader("User-Agent"));
String browser = userAgent.getBrowser.getName();
String os = userAgent.getOperatingSystem().getName();
@chumpy
chumpy / yaml_to_xml.rb
Created January 29, 2012 00:14
yaml to xml conversion
#require 'active_support/core_ext'
class YamlToXml
def self.yaml_to_xml file_to_read, file_to_write
doc = String.new
File.open( file_to_read ) { |yf| doc << YAML.parse( yf ).transform.to_xml }
File.open( file_to_write, 'w' ) { |f| f.write( doc ) }
end
def self.xml_to_yaml file_to_read, file_to_write
@chumpy
chumpy / yaml_compare.rb
Created January 29, 2012 00:20
compare two yaml files in ruby
#require 'active_support/core_ext'
class YamlCompare
def self.compare_keys first_file_info, second_file_info, results_location
first_file = Hash.new
second_file = Hash.new
deltas_file = Hash.new
File.open( first_file_info[:file_location] ) { |yf| first_file = YAML.load( yf ) }
File.open( second_file_info[:file_location] ) { |yf| second_file = YAML.load( yf ) }
first_file[first_file_info[:root]].each_pair do |k,v|
@chumpy
chumpy / restful_auth_basic.rb
Created January 29, 2012 00:29
Basic Auth w/Restful Authentication
# Here’s a way to do http basic authentication and tie it in
# to the Restful Authentication mechanism to make current_person accessible:
def authenticate_person
authenticate_or_request_with_http_basic do |login, password|
person = Person.authenticate(login, password)
return false if !person or person.nil?
session[:person_id] = person.id
end
end
@chumpy
chumpy / add_ppp0_route.sh
Created February 21, 2012 04:00
Adds ppp0 route to kernel route list to support IPSec VPN
#! /bin/bash
ifconfig -a ppp0 | grep inet | awk '{print $2}' | xargs -0 -I ip sudo route add default gw ip ppp0
@chumpy
chumpy / uninstall_gems.sh
Created February 22, 2012 04:01
Uninstall all gems
#! /bin/bash
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@chumpy
chumpy / dep_warning.txt
Created April 13, 2012 22:41
deprecation warning
gem -v = 1.8.17
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
@chumpy
chumpy / gem_list.txt
Created April 13, 2012 22:46
gem list
$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.12)
actionpack (2.3.12)
activerecord (2.3.12)
activeresource (2.3.12)
activesupport (2.3.12)
addressable (2.2.6)
@chumpy
chumpy / capybara_cheat_sheet.md
Created October 23, 2012 22:46 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet

Capybara Cheat Sheet

Navigating

  visit('/projects')
  visit(post_comments_path(post))