Skip to content

Instantly share code, notes, and snippets.

View laktek's full-sized avatar

Lakshan Perera laktek

View GitHub Profile
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;
"test=abc&check=1".split("&").inject({}) {|result, elem| t=elem.split("="); result[t[0]] = t[1]; result }
>> {"test"=>"abc", "check"=>"1"}
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"])
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
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" );
#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/
var sys = require("sys");
var net = require("net");
var http = require("http");
function createTestServer(){
return new testServer();
};
function testServer(){
var server = this;
/**
* jQuery plugin to detect clicks outside an element
*
* Copyright (c) 2010 Vesess Inc. (vesess.com)
* Licensed under the MIT (MIT-LICENSE.txt) licenses.
*
*/
(function($){
$.fn.outsideClick = function(optional_params){
/**
* jQuery plugin to detect clicks outside an element
*
* Copyright (c) 2010 Vesess Inc. (vesess.com)
* Licensed under the MIT (MIT-LICENSE.txt) licenses.
*
*/
(function($){
$.fn.outsideClick = function(optional_params){
var my_function_expression = function(){};
var mocked = nodemock.mock("foo").takes(20, my_function_expression).calls(my_function_expression, 30, [10, 20])