Skip to content

Instantly share code, notes, and snippets.

require 'prawn'
define_grid columns: 3, rows: 1, gutter: 0
3.times do |i|
grid(0,i).bounding_box do
# How can I the left and right borders with a line size of 5
# and the top and bottom borders with a line size of 1?
stroke_bounds
end
def view
@ibs = <<-EOF
this is a test
testing
1 2 3
4 5 6
EOF
#=> "this is a test\ntesting\n\n1 2 3\n 4 5 6"
end
require 'prawn'
def name
'Andy'
end
# When I don't specify a block variable, @name is neglected and the output
# to a pdf file is (approximately): "\nmore text"
pdf = Prawn::Document.new do
text name
##########
json_object.is_a?(String) # Returns true if json_object is an array, else false
json_object.is_a?(Array) # Returns true if json_object is an array, else false
############
case json_object
when String
#do something here if string
// how can I chain these two 'on' functions? I'm not sure this is working correctly ...
$('input#hospital_name, input#address').on "autocompleteselect", (e,ui) ->
alert 'selected'
.on "autocompletechange" (e,ui)->
alert 'changed'
// I have a bunch of inputs[type=text] that contains the following ids: #name, #address, #city, #state, #zipcode
// $current will be set to the input#name field.
$current = $('input#name')
// I want to select all $('input') but omit the $current .. how can I do this?
$('input')
@advorak
advorak / test.rb
Last active August 29, 2015 13:58
require 'active_support/all'
module Asdf
def self.new(connection_name, options)
classified_connection_name = connection_name.to_s.classify
self.class_eval <<-EOF
class #{classified_connection_name}
end
%w(aaa bbb ccc ddd).each do |letters|
class #{letters.classify} < #{classified_connection_name}
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.4'
group :development do
gem 'sqlite3', '1.3.8'
end
require 'active_support/all'
require 'active_record'
class WordpressConnection < ActiveRecord::Base
end
WordpressConnection.establish_connection adapter: 'mysql2', username: 'root', password: 'password', host: 'localhost', database: 'wordpress_wordpress'
class WordpressConnection::User < WordpressConnection
self.table_name = 'wp_users'
@advorak
advorak / andy.rb
Last active August 29, 2015 13:58
is it appropriate in a class, for a getter method of an instance variable which happens to be an array, to dup the variable so that such things as getter#push cannot be called on them?
class Andy
def initialize
@andytest = []
end
attr_reader :andytest
end
__END__