Skip to content

Instantly share code, notes, and snippets.

@abevoelker
abevoelker / prawn_test.rb
Created September 2, 2011 15:19
Prawn stepladder header issue (fixed)
require 'prawn'
Prawn.debug = true
Prawn::Document.generate("test.pdf", :page_layout => :landscape) do |pdf|
Header = Struct.new(:title, :width)
headers = [Header.new("Header\nOne", 50),
Header.new("Header\nTwo", 50),
Header.new("Header\nThree", 50)]
pdf.stroke_bounds
@abevoelker
abevoelker / jruby_file_fix.rb
Created October 5, 2011 13:45
JRuby File#size monkeypatch
# Apparently JRuby doesn't have a File#size (instance) method,
# but does have the equivalent class method
if !File.method_defined? :size
class File
def size
File.size(path)
end
end
end
@abevoelker
abevoelker / property_names_patch.rb
Created December 16, 2011 20:56
DataMapper equivalent to ActiveRecord attribute_names
module DataMapper::Model
def property_names
properties.map { |m| m.name.to_s }
end
end
@abevoelker
abevoelker / xrandr.sh
Created December 31, 2011 03:25
Triple head settings
#!/bin/bash
LEFT="DVI-1"
MIDDLE="DisplayPort-1"
RIGHT="DVI-0"
xrandr --output $LEFT --auto --rotate left --pos 0x0
xrandr --output $MIDDLE --auto --right-of $LEFT
xrandr --output $RIGHT --auto --rotate left --right-of $MIDDLE
@abevoelker
abevoelker / error.txt
Created March 5, 2012 15:26
bundle exec ruby -I lib test/test_pygments.rb 2>&1 | tee error.txt
Run options:
# Running tests:
............................/home/abe/.rvm/gems/[email protected]/gems/rubypython-0.5.3/lib/rubypython.rb:141: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0029 p:---- s:0123 b:0123 l:000122 d:000122 CFUNC :PyImport_ImportModule
c:0028 p:0064 s:0119 b:0119 l:000118 d:000118 METHOD /home/abe/.rvm/gems/[email protected]/gems/rubypython-0.5.3/lib/rubypython.rb:141
@abevoelker
abevoelker / gist:2123152
Created March 19, 2012 18:32
concrete table inheritance
# app/models/wizard.rb
class Wizard
# shared instance methods go here
def self.all_visible_subwizards
descendants.entries.select{|d| d.visible?}.sort
end
end
# lib/wizard_fields.rb
=====================================================
PROGRESS stack trace as of Fri Apr 27 20:56:38 2012
=====================================================
Startup parameters:
-pf C:\Progress\OpenEdge\startup.pf,-cpinternal ISO8859-1,-cpstream ISO8859-1,-cpcoll Basic,-cpcase Basic,-d mdy,-numsep 44,-numdec 46,(end .pf),-param C:\Users\Abe\Desktop\abl-zmq\lib\zmq\test.p
Exception code: C0000005 ACCESS_VIOLATION
Fault address: 7358345E 51BAE0:76EBDFA5
Registers:
DEF VAR mString AS MEMPTR NO-UNDO.
DEF VAR iCheckAddr AS INT NO-UNDO.
DEF VAR cSentence AS CHAR NO-UNDO INITIAL "The quick brown dog jumps over the lazy fox".
SET-SIZE(mString) = LENGTH(cSentence) + 1. /* Extra one is for \0 byte that gets put @ end */
PUT-STRING(mString, 1) = cSentence.
RUN memchr(GET-POINTER-VALUE(mString) + 4,
ASC("b"),
LENGTH(cSentence) + 1,
#!/usr/local/bin/perl
#!/usr/bin/env perl
#!/bin/sh
######################################################################
# unichars - list characters for one or more properties
#
# Tom Christiansen <[email protected]>
# v1.0: Fri Oct 22 23:05:16 MDT 2010
# v1.2: Tue Oct 26 08:28:25 MDT 2010
require 'java'
require 'itextpdf-5.2.0.jar'
require 'itext-xtra-5.2.0.jar'
java_import java.io.FileOutputStream
java_import com.itextpdf.text.pdf.PdfReader
java_import com.itextpdf.text.pdf.AcroFields
java_import com.itextpdf.text.pdf.XfaForm
java_import com.itextpdf.text.pdf.PdfStamper