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
var sys = require("sys"); | |
var net = require("net"); | |
var http = require("http"); | |
function createTestServer(){ | |
return new testServer(); | |
}; | |
function testServer(){ | |
var server = this; |
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
#Changing the default behavior of field Errors | |
# config/initializers/field_errors.rb | |
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
msg = instance.error_message | |
if html_tag =~ /<(input|textarea|select)[^>]+class=/ | |
class_attribute = html_tag =~ /class=['"]/ | |
html_tag.insert(class_attribute + 7, "error") | |
elsif html_tag =~ /<(input|textarea|select)/ | |
first_whitespace = html_tag =~ /\s/ |
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
import mx.collections.ArrayCollection; | |
import mx.rpc.events.ResultEvent; | |
import com.adobe.serialization.json.JSON; //download from http://code.google.com/p/as3corelib/ | |
function initateGame(playerId):void | |
{ | |
var dataToSave = [playerId]; | |
// Point the request to the script that will handle the JSON | |
var request:URLRequest = new URLRequest( "http://localhost:8000" ); |
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
if has("folding") | |
set foldenable | |
set foldmethod=syntax | |
set foldlevel=1 | |
set foldnestmax=2 | |
set foldtext=strpart(getline(v:foldstart),0,50).'\ ...\ '.substitute(getline(v:foldend),'^[\ #]*','','g').'\ ' | |
" automatically open folds at the starting cursor position | |
" autocmd BufReadPost .foldo! | |
endif |
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
require 'net/http' | |
class ServerProxy | |
def self.call(env) | |
if env["PATH_INFO"] =~ /^\/server_proxy/ | |
request = Rack::Request.new(env) | |
params = request.params | |
Net::HTTP.start(params["service_url"]) {|http| | |
req = Net::HTTP::Get.new(params["service_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
"test=abc&check=1".split("&").inject({}) {|result, elem| t=elem.split("="); result[t[0]] = t[1]; result } | |
>> {"test"=>"abc", "check"=>"1"} |
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
div.pagination { | |
background-color:#F7F7F7; | |
float:left; | |
margin:1em 0 5px; | |
padding:10px; | |
width:630px; | |
} | |
div.pagination a, div.pagination span { | |
border:1px solid #CCDBE4; | |
color:#3666D4; |
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 Message | |
class AbstractMessage | |
attr_accessor :body, :api_version, :api_format, :message_type, :source_id, :destination_id, :checksum | |
def initialize | |
@api_version = 1 | |
@api_format = 1 | |
@message_type = 1 |
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
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb | |
require 'open-uri' | |
def download(from, to = from.split("/").last) | |
#run "curl -s -L #{from} > #{to}" | |
file to, open(from).read | |
rescue | |
puts "Can't get #{from} - Internet down?" | |
exit! |
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
class Message | |
attr_accessor :body | |
def initialize | |
@api_version = 1 | |
@api_format = 1 | |
@message_type = 1 | |
@source_id = 64071 |