Skip to content

Instantly share code, notes, and snippets.

def bar_event_severity
data = []
data_labels = []
%w(High Medium Low).each do |x|
sym = x.downcase.to_sym
unless params[sym].blank?
data << params[sym].to_i
data_labels << "#{x} Severity"
end
end
class TestItReceiver
# show text takes a string, but may have some other params for us to look through
def show_text(string, *params)
puts string
end
def show_text_with_positioning(array, *params)
# make use of the show text method we already have
# assuming we don't care about positioning right now and just want the text
show_text(array.select{|i| i.is_a?(String)}.join(""), params)
end
receiver = TestItReceiver.new
pdf = PDF::Reader.file("sample.pdf", receiver)
$tumblr_user = Tumblr::User.new('[email protected]', 'ourtumblrpassword')
Tumblr.blog = 'ourtumblrcmsblog'
def tumblr_cms(tag)
post = Tumblr::Post.first(:tagged => tag)
return nil if post.nil?
<%= tumblr_cms("home_page_top") %>
>> VinApi.find("1HGCM82633A004352").year
=> "2003"
>> VinApi.find("1HGCM82633A004352").model
=> "ACCORD EX"
>> puts VinApi.find("1HGCM82633A004352").attributes.to_yaml
---
model: ACCORD EX
body_style: COUPE
country: UNITED STATES
vin: 1HGCM82633A004352
class VinApi < ActiveResource::Base
headers["X-VinApiKey"] = "YOUR_API_KEY_GOES_HERE"
self.site = "http://vinapi.skizmo.com"
self.element_name = "vin"
end
<h2>Testing home top for speedeals.com</h2>
<b>Really?</b>
<ul>
<li>Hello THere...</li>
</ul>
@pullmonkey
pullmonkey / vinapi.php
Created November 16, 2010 03:40
Way to use the Skizmo VINAPI in PHP
<?php
function decodeVIN($vin){
$curl = curl_init();
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_URL, 'http://vinapi.skizmo.com/vins/'.$vin.'.xml');
curl_setopt ($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'X-VinApiKey: YOUR_API_KEY_GOES_HERE'));
$result = curl_exec ($curl);
curl_close ($curl);
return $result;
}
@pullmonkey
pullmonkey / simple_rotated_box_using_cairo.rb
Created November 19, 2010 21:14
Simple Rotated Box Cairo Example for pullmonkey.com
require 'rubygems'
require 'cairo'
class Box
# height and width for the rectangle, angle for the rotation
attr_accessor :height, :width, :angle
def initialize(height=200, width=200, angle=45)
@height, @width, @angle = [height, width, degrees_to_radians(angle)]
# The first argument for a surface is the filename, the next two are our canvas/surface size.