Skip to content

Instantly share code, notes, and snippets.

View adriand's full-sized avatar

Adrian Duyzer adriand

  • Hamilton, Ontario
View GitHub Profile
@adriand
adriand / codepackr_json_conversion_example_2.json
Created September 11, 2026 19:01
Codepackr example EDI => JSON output (incorrect, incomplete) - attempt 2 (no newlines included)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "ASC_X12_SEMANTIC_SCHEMA",
"standard": "ANSI_X12",
"version": "004010",
"generatedAt": "2026-09-11T19:00:46.539Z",
"interchange": {
"sender": "TEDIBUYER",
"senderQualifier": "ZZ",
"receiver": "WIDGETWORKS",
@adriand
adriand / codepackr_json_conversion_example.json
Last active September 11, 2026 19:00
Codepackr example EDI => JSON output (incorrect, incomplete) - attempt 1 (newlines included)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "ASC_X12_SEMANTIC_SCHEMA",
"standard": "ANSI_X12",
"version": "004010",
"generatedAt": "2026-09-11T18:42:20.557Z",
"interchange": {
"sender": "TEDIBUYER",
"senderQualifier": "ZZ",
"receiver": "WIDGETWORKS",
@adriand
adriand / tediware_json_conversion_example.json
Last active September 11, 2026 18:43
Tediware example EDI => JSON output (correct, complete)
{
"interchanges": [
{
"interchange_control_header_ISA": {
"authorization_information_qualifier_01": "no_authorization_information_present_no_meaningful_information_in_i02_00",
"security_information_qualifier_03": "no_security_information_present_no_meaningful_information_in_i04_00",
"interchange_id_qualifier_05": "mutually_defined_ZZ",
"interchange_sender_id_06": "TEDIBUYER",
"interchange_id_qualifier_07": "duns_dun_bradstreet_01",
"interchange_receiver_id_08": "WIDGETWORKS",
@adriand
adriand / tenon_faq.md
Created October 14, 2014 15:11
Tenon FAQ

Q: I changed a SASS variable but the change is not reflected in Tenon. I even restarted my app and there's no change!

A: Delete the entire tmp/cache folder and try again

Q: How do I install the config file, main menu nav, and custom colours file into my app?

A: bundle exec rails generate tenon:install

Q: I got the error "Could not infer a decorator for MyModel" but the decorator is there!

Ruby/Rails
- Use latest stack (Ruby 2.1.x, Rails 4.x, Postgresql)
- Prefer the new hash syntax, but use the old one when necessary (ie. when you need to use strings as keys)
- Code in ActiveRecord models should pertain directly to storing or retrieving data
- Use Draper to decorate model instances and test your decorators with RSpec (app/decorators is the place for this)
- Put business logic into service classes and test them with RSpec (app/services is a fine place for this, you can get more specific if your services folder gets fat)
- I like to name my service classes after what they do, or give them cute names occasionally (AddsProductstoCart or CartStuffer)
- Don’t hesitate to namespace related models or services into modules.
- Use Resque and Redis for background job handling.
- Testing should be the rule, not the exception
Ruby/Rails
- Use latest stack (Ruby 2.1.x, Rails 4.x, Postgresql)
- Prefer the new hash syntax, but use the old one when necessary (ie. when you need to use strings as keys)
- Code in ActiveRecord models should pertain directly to storing or retrieving data
- Use Draper to decorate model instances and test your decorators with RSpec (app/decorators is the place for this)
- Put business logic into service classes and test them with RSpec (app/services is a fine place for this, you can get more specific if your services folder gets fat)
- I like to name my service classes after what they do, or give them cute names occasionally (AddsProductstoCart or CartStuffer)
- Don’t hesitate to namespace related models or services into modules.
- Use Resque and Redis for background job handling.
@adriand
adriand / when.rb
Created October 11, 2013 14:35
Ruby case/when for class
# this does not work:
case @object.class
when ModelHome then path_for_model_home
end
# this works:
case @object
when ModelHome then path_for_model_home
end
def get_events
# TODO: remove - this is for testing and benchmarking the two implementations
if false
(conditions ||= []) << "user_id IN (#{params[:employee_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:employee_ids].blank?
(conditions ||= []) << "client_id IN (#{params[:client_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:client_ids].blank?
(conditions ||= []) << "group_id IN (#{params[:group_ids].split('-').map{|i| i.to_i}.join(',')})" unless params[:group_ids].blank?
@events = conditions.blank? ? [] : Event.all(:conditions => ["(starts_on >= ? AND ends_on <= ?) AND (#{conditions.join(' OR ')})", Time.at(params[:start].to_i), Time.at(params[:end].to_i)], :include => :group)
render :json => { :events => @events.map {|e| e.attrs_for_json(params[:employee_ids], params[:client_ids]) } }
else
@adriand
adriand / Monokai.dvtcolortheme
Created August 9, 2012 17:41 — forked from kristoferjoseph/Monokai.dvtcolortheme
Molokai theme for XCode4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.995968 0.995968 0.995968 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.995968 0.995968 0.995968 1</string>
@adriand
adriand / gist:3198178
Created July 29, 2012 11:58
ActiveMerchant and PayPal
# controller
def notify
order = Order.capture_payment(request.raw_post)
render :nothing => true
end
# Order model
def self.capture_payment(raw_post)