Skip to content

Instantly share code, notes, and snippets.

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
require 'rubygems'
require 'prawn'
require "prawn/measurement_extensions"
require 'ruby-debug'
# Put ignored bmml files here, one per line
src = ARGV[0]
output = ARGV[1]
require 'rubygems'
require 'prawn'
require "prawn/measurement_extensions"
require 'ruby-debug'
balsamiq = "/Volumes/Macintosh HD/Applications/Balsamiq Mockups.app/Contents/MacOS/Balsamiq Mockups"
# Put ignored bmml files here, one per line
ignored_files = [
"blank.bmml",
" LINE 1224, ZendCoding 1.3.1 for textmate
" Hack to support auto comments
" /Users/sr3d/Library/Application Support/TextMate/Pristine Copy/Bundles/Zen Coding.tmbundle/Support/zendcoding/zen_core.py
def get_comment(self):
if self.name == 'div' and ( self.get_attribute('id') != None or self.get_attribute('class') != None):
s = '<!-- '
if self.get_attribute('id') != None:
s = s + '#' + self.get_attribute('id')
#!/usr/bin/env ruby
# This script will automatically export all the Balsamiq mock files to PDF and bundle them up
# into a nice PDF. Just drop this script into the folder containing the mock files and
# execute it from the command-line
#
# For the PDF to work, you'd need to install "prawn" and "prawn-fast-png" gem, otherwise the PDF
# creation will be very slow.
#
# Currently this script has been tested with Balsamiq Next.161 build (05/28/2010)
class Budget < ActiveRecord::Base
belongs_to :event
belongs_to :category
scope :for_event, lambda {|event_id| where("event_id = ?", event_id ) },
:select => '*, ( SELECT SUM(amount) FROM expenses WHERE event_id = budgets.event_id GROUP BY category_id ) AS total'
# the above code error out, wrong params, 3 for 2
Paperclip - Factory_Girl for Rails 3 beta 4
Factory.define :contacts_short_csv, :class => 'CsvFile' do |f|
include ActionDispatch::TestProcess
f.csv { fixture_file_upload( 'files/contacts_short.csv.upload', 'text/csv') }
f.account_id { 1 }
end
My model is
Dir.glob("*.b").each do |file|
if File.size(file) < 62.kilobytes
return # bail out early
contact = true
`mv #{file} #{file}.old &&`
`sed 's/<\/Listings>//g' #{file}.old > #{file}`
File.rm file
set nocompatible
syntax on
filetype plugin indent on
filetype plugin on
colorscheme vividchalk
set nu " show line number
set smartindent
set autoindent
set smarttab
def string2png( string, output )
image = Magick::Image.new 1,string.length
for i in 0 .. string.length
color = '#%02X0000' % string[i]
pixel = Magick::Pixel.from_color color
image.pixel_color 0, i, pixel
end
image.compression = ZipCompression
image.write("png8:"+ output)