Skip to content

Instantly share code, notes, and snippets.

View andreacfm's full-sized avatar

Andrea Campolonghi andreacfm

View GitHub Profile
@andreacfm
andreacfm / gmaps_add_street_view.cfm
Created February 19, 2011 18:56
street view example bases on ray camden post
<script>
function init() {
ColdFusion.Map.addEvent("mainMap","click",function(overlay,overlaylnglt) {
address = arguments[arguments.length-1];
var loc = new GLatLng(address.lat(),address.lng());
panoramaOptions = { latlng:loc };
var myPano = new GStreetviewPanorama(document.getElementById("streetDiv"), panoramaOptions);
});
}
</script>
print "What is your name? "
$stdout.flush
name = gets
puts 'Hi ' + name + '!!!' + name
# => Hi andrea
# !!!
@andreacfm
andreacfm / ruby_gets_chomp.rb
Created June 11, 2011 23:11
ruby_gets_chomp
print "What is your name? "
$stdout.flush
name = gets.chomp
puts 'Hi ' + name + '!!!' + name
#=> Hi andrea!!!
@andreacfm
andreacfm / railo_mongodb_cache_benchmark.cfm
Created June 20, 2011 12:58
Railo MongoDb Cache Performamce
<cfset start = gettickcount()>
<cfloop from="1" to="1000" index="i">
<cfcache action="put" id="a#i#" value="#i#">
<cfcache action="get" id="a#i#" name="v">
<cfcache action="put" id="b#i#" value="#{value = i}#">
<cfcache action="get" id="b#i#" name="v">
</cfloop>
<cfset end = gettickcount()>
<cfoutput>#end - start# millis</cfoutput>
@andreacfm
andreacfm / postgres_basic.sh
Created June 30, 2011 11:02
postgres basic
createuser nome_utente -P
#promt
createdb nome_db -O nome_utente
@andreacfm
andreacfm / post_instance_eval.rb
Created July 2, 2011 11:05
post_instance_eval
include My_package;
My_module.configure do
set :my_setting, :my_value
set :another_setting, :another_value
end
module Andrea
module My_module
def self.configure
yield
end
def self.set(arg)
puts arg
module Andrea
module My_module
def self.configure &block
instance_eval &block
end
def self.set(arg)
puts arg
@andreacfm
andreacfm / rubygems_commands.sh
Created July 5, 2011 08:06
rubygems_commans
#owner
$ gem owner gem_name --add rubygems_user
$ gem owner gem_name --remove rubygems_user
require 'spec_helper'
describe ModelDecorator do
include Rails.application.routes.url_helpers
# see https://github.com/jcasimir/draper/issues/60
before(:each) {
c = ApplicationController.new
c.request = ActionDispatch::TestRequest.new