Skip to content

Instantly share code, notes, and snippets.

task :cron => :environment do
@config = YAML.load_file("#{RAILS_ROOT}/config/helpdesk.yml")
@config = @config["EMAIL"]["incoming"][RAILS_ENV].to_options
@fetcher = Fetcher.create({:receiver => Helpdesk::TicketNotifier}.merge(@config))
@fetcher.fetch
end
@starrhorne
starrhorne / gist:466898
Created July 7, 2010 16:19
Cairo warped / curved text demo in ruby. Ported from example included in pycairo
require 'cairo'
require 'rubygems'
require 'ruby-debug'
def warp_path(context, &block)
first = true
context.copy_path.each do |type, points|
case type
<form id="google-voice" action="https://clients4.google.com/voice/embed/webButtonConnect" method="post">
<input type="hidden" name="phone_call[buttonId]" value="<YOUR API KEY>" />
<input type="hidden" name="phone_call[showCallerNumber]" value="1" />
<ul>
<li>
<label>Your Name</label>
<input type="text" name="phone_call[callerNumber]" />
</li>
$("#google-voice").submit(function(e){
e.preventDefault();
$.post("/phone_calls", $(this).serialize(), function(data){
if(data=="ok=true"){
console.log("success");
}
else{
console.log("failure");
class PhoneCallsController < ApplicationController
def create
http = Net::HTTP.new('clients4.google.com', 443)
http.use_ssl = true
path = '/voice/embed/webButtonConnect'
request_params = params[:phone_call].map { |k, v| "#{ CGI.escape(k) }=#{ CGI.escape(v) }" }.join("&")
request_headers = {}
resp, data = http.post(path, request_params, request_headers)
#!/usr/bin/python
import sys
from fontTools import ttLib
FONT_SPECIFIER_NAME_ID = 4
FONT_SPECIFIER_FAMILY_ID = 1
def shortName( font ):
"""Get the short name from the font's names table"""
name = ""
family = ""
require 'rack/utils'
class FlashSessionCookieMiddleware
def initialize(app, session_key = '_session_id')
@app = app
@session_key = session_key
end
def call(env)
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
$("#uploadify").uploadify({
// Eval the response
'onComplete' : function(a, b, c, response){ eval(response) },
// And set the accept header to application/javascript
'scriptData' : {
'<%%= session_key_name %>' : '<$%= u cookies[session_key_name] %>',
'_http_accept': "application/javascript"
},
# Rakefile
desc "Create new color swatches"
task :swatches do
require "yaml"
YAML.load_file("swatches.yml").each do |name, color|
p "Creating: #{name} (#{color}) => images/colors/#{name}.png"
%x[ convert -size 16x16 xc:white -draw "stroke #666666 fill white rectangle 0,0 15,15" -draw "stroke white fill #{color} rectangle 1,1 14,14" "images/colors/#{name}.png" ]
end
# swatches.yml
black: "#0F0F0F"
blue: "#3055A0"
gray: "#949A9F"
green: "#4D8756"
light_green: "#92C14F"
navy: "#304264"
orange: "#DA7A2D"
red: "#C31E38"
teal: "#477D79"