Skip to content

Instantly share code, notes, and snippets.

View rubenfonseca's full-sized avatar

Ruben Fonseca rubenfonseca

View GitHub Profile
$(document).ready(function(){
if(!("WebSocket" in window)) {
alert("Sorry, the build of your browser does not support WebSockets. Please use latest Chrome or Webkit nightly");
return;
}
ws = new WebSocket("ws://localhost:8080/");
ws.onmessage = function(evt) {
data = eval("(" + evt.data + ")");
var p = $("<div class='tweet' style='display:none'><div class='content'><a class='main-screenname' href='http://www.twitter.com/" + data.user.screen_name + "/status/" + data.id + "' target='_blank'>" + data.user.screen_name + "</a> " + data.text + "</div></div>");
@rubenfonseca
rubenfonseca / macruby_opencl_test
Created January 23, 2010 17:05
OpenCL MacRuby quick experiment
~/luser/MacRuby[master]% macruby -e 'puts OpenCL.devices.map(&:info)'
{:name=>"GeForce 9400 GT", :vendor=>"NVIDIA", :version=>"OpenCL 1.0 ", :type=>:gpu, :max_compute_units=>4, :max_work_item_dimensions=>140733193388035, :max_work_item_sizes=>[512, 512, 64], :max_work_group_size=>512, :max_clock_frequency=>1350, :address_bits=>32, :max_mem_alloc_size=>128, :global_mem_size=>512, :error_correction_support=>false, :local_mem_type=>"local", :local_mem_size=>16, :max_constant_buffer_size=>64, :queue_properties=>[:profiling_enable], :image_support=>true, :max_read_image_args=>128, :max_write_image_args=>8, :image2d_max_width=>8192, :image2d_max_height=>8192, :image3d_max_width=>2048, :image3d_max_height=>2048, :image3d_max_depth=>2048, :extensions=>"cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_APPLE_gl_sharing cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions "}
{:name=>"GeForce 9400 GT", :vendor=>"NVIDIA", :version=>"OpenCL 1.0 ", :type=>:g
@rubenfonseca
rubenfonseca / test_macruby_opencl.rb
Created January 23, 2010 20:25
OpenCL Macruby Example
OpenCL.devices.each do |device|
info = device.info
puts "Trying on #{info[:name]} #{info[:vendor]} #{info[:version]} [#{info[:type]}]"
context = device.create_context
queue = context.create_command_queue
program = context.create_program <<EOF
// OpenCL kernel that computes the square of an input array
__kernel square(
__global float* input,
Trying on GeForce 9400 GT NVIDIA OpenCL 1.0 [gpu]
1073741824.0
Trying on GeForce 9400 GT NVIDIA OpenCL 1.0 [gpu]
1073741824.0
Trying on Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz Intel OpenCL 1.0 [cpu]
1073741824.0
require 'rubygems'
require 'activity_streams'
require 'open-uri'
twitter = 'http://api.cliqset.com/feed/?svcuser=rubenfonseca&feedid=twitternotesposted'
feed = ActivityStreams::Feed.from_xml(open(twitter).read)
feed.entries.size #=> 20
feed.entries.first.verbs.size #=> 1
feed.entries.first.verbs.first #=> "http://activitystrea.ms/schema/1.0/post"
We couldn’t find that file to show.
@rubenfonseca
rubenfonseca / _form.html.haml
Created October 27, 2010 22:24
user has_many groups
- form_for @user do |f|
.small= f.error_messages
%fieldset
%legend= t(:please_fill_the_following_fields)
.box
= f.label :name, User.human_attribute_name(:name)
= f.text_field :name, :style => 'width: 500px'
require 'rubygems'
require 'oauth'
consumer = OAuth::Consumer.new 'ds1UTK4sT3R5MVhYIYV6w', 'RtqyirueGdzUt0tpbuuYnZAxUv71E3xrxxpfnkxt4', { :site => 'http://hireme.goplanapp.com' }
request = consumer.get_request_token
puts request.authorize_url
sleep 20 # give us time to authenticate
require 'rubygems'
require 'oauth'
require 'json'
consumer = OAuth::Consumer.new 'ds1UTK4sT3R5MVhYIYV6w', 'RtqyirueGdzUt0tpbuuYnZAxUv71E3xrxxpfnkxt4', { :site => 'http://hireme.goplanapp.com' }
req = consumer.get_request_token
puts req.authorize_url
sleep 20
Biscates.Location = (function() {
var WATCH_ID;
var POSITION;
var GEOLOCATION_OPTIONS = {
enableHighAccuracy: true,
maximumAge: 600000,
timeout: 30000 // 30 seconds
};
function _initGeolocation() {