Skip to content

Instantly share code, notes, and snippets.

@aaroncampos
aaroncampos / import_steps.rb
Created February 21, 2009 01:16
Testing CSV import with Cucumber and Ruport
require 'tempfile'
Given /^an import file exists with the following data:$/ do |field_table|
report = Ruport::Data::Table.new(:column_names => field_table.hashes.first.keys)
field_table.hashes.each { |hash| report << hash }
@current_import_file = Tempfile.new("import.csv")
@current_import_file << report.to_csv
@current_import_file.close
end
/*
* From http://www.evernote.com/pub/cdunn/code#3536832e-1337-4b80-bbb1-830dd9706476
*/
.foo {
min-height:100px;
height: auto !important;
height: 100px;
}
@aaroncampos
aaroncampos / base_app_template.rb
Created June 26, 2009 18:23
My Rails template using Haml, Compass, make_resourceful, shoulda and, optionally, heroku
# This template assumes you have the HAML and Compass gems installed.
run "haml --rails ."
run "compass --rails -f blueprint --sass-dir public/stylesheets/sass --css-dir public/stylesheets ."
run "rm public/index.html"
plugin 'jrails', :git => 'git://github.com/aaronchi/jrails.git'
plugin 'make_resourceful', :git => 'git://github.com/hcatlin/make_resourceful.git'
plugin 'shoulda', :git => 'git://github.com/thoughtbot/shoulda.git'
function dialogCallback(filenames){
alert(filenames[0]);
}
function selectResultFile() {
var options = {
multiple: false,
title: "Open file",
types: ['*'],
typesDescription: "All files",
// Result File HTTP Client
function resultHTTPClient() {
var result_client = Titanium.Network.createHTTPClient();
result_client.open("POST", _hostname + "/endpoint");
var auth = "Basic " + Ext.util.base64.encode(_username + ":" + _password);
result_client.setRequestHeader("Authorization", auth);
result_client.setRequestHeader("Accept", "application/xml");
result_client.onreadystatechange = function() {
if (this.readyState == 4) {
When /^the MyMedLab order is posted to BioIQ with username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
@response_code = post('api/orders.xml',
@mml_order.to_xml(:root => 'order'),
{"Content-type" => "text/xml",
:authorization => ActionController::HttpAuthentication::Basic.
encode_credentials(username, password)})
@parsed_response = Nokogiri::Slop(@response.body)
end
{
datetime: Wed Aug 04 13:00:13 UTC 2010,
receipts: [
{ ... },
{ ... }
]
}
function(doc, prev) {
prev.check_count += 1;
prev.total += doc.total;
prev.tax += doc.tax;
prev.subtotal += doc.subtotal;
prev.payment += doc.payment;
prev.tender += doc.tender;
prev.discount += doc.discount;
prev.coupon += doc.coupon;
;; Helpful macro function
(defun my-macro-query (arg)
"Prompt for input using minibuffer during kbd macro execution.
With prefix argument, allows you to select what prompt string to use.
If the input is non-empty, it is inserted at point."
(interactive "P")
(let* ((query (lambda () (kbd-macro-query t)))
(prompt (if arg (read-from-minibuffer "PROMPT: ") "Input: "))
(input (unwind-protect
(progn
class ActiveSupport::TimeWithZone
def to_json(*args)
"{\"$date\": #{utc.to_i * 1000}}"
end
end