Skip to content

Instantly share code, notes, and snippets.

View zorn's full-sized avatar
💸
Elixir Contractor For Hire

Mike Zornek zorn

💸
Elixir Contractor For Hire
View GitHub Profile
# _form.html.erb
<%= f.fields_for :file_attachments do |builder| %>
<%= render 'file_attachment_fields', :f => builder %>
<% end %>
# _file_attachment_fields.html.erb
<div class="clearfix fields">
<label>Name:</label>
<div class="input">
<%= f.text_field :name %>
@zorn
zorn / gist:1468633
Created December 12, 2011 19:13
New Mailplane ProfitTrain script
-- The following is an AppleScript function ProfitTrain will call when you choose "Email Client..."
-- under an invoice. Before using the built in AppleScript ProfitTrain will look for
-- this user AppleScript file at:
-- /Users/[you]/Library/Application Support/ProfitTrain/email_invoice_using_user_script.scpt
-- By edting this file you can further customize the email with different subject lines, etc.
-- and/or use an alternative email client that is not supported by Billable by default.
-- Script using Mailplane
@zorn
zorn / gist:1556231
Created January 3, 2012 18:38
Making an estimate in ProfitTrain
If you edit an invoice there is a status pulldown. You can change this to Estimate and it'll will make things work right.
Sadly you can't "publish" an estimate (else it would be turned back into an "sent invoice") so use the context menu via right click to access publish actions directly.
http://media.clickablebliss.com/support/images/right_click_actions.png
In the future I'm hopeful to make estimate first class objects.
Hope this info helps. Let me know if you have any follow up questions.
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: objectsWillLoad
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: Query for Table
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: objectsWillLoad
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: Query for Table
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: objectsWillLoad
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: Query for Table
Jan 16 10:43:43 unknown BrooklynMuseum[610] <Warning>: objectsWillLoad
Jan 16 10:43:44 unknown BrooklynMuseum[610] <Warning>: Query for Table
@zorn
zorn / gist:1761047
Created February 7, 2012 18:12
Philly CocoaHead Categories
// Mike Zornek
// I use these a ton for quick scans of strings:
@interface NSString (CBAdditions)
- (BOOL)cb_containsString:(NSString *)aString;
- (BOOL)cb_containsString:(NSString *)aString ignoringCase:(BOOL)flag;
@end
@implementation NSString (CBAdditions)
- (BOOL)cb_containsString:(NSString *)aString
What Zorn did:
* Removed all the CAPITAL <B> and </B> tags.
* Replaced all the <b> with <strong>
* Replaced all the </b> with </strong>
* Replaced all the <i> with <em>
* Replaced all the </i> with </em>
BTW the open counts on those didn't 100% match the close counts. If wanted I could try to find out which files have more opens than closes or more closes than opens for manual cleanup.
@zorn
zorn / gist:2122205
Created March 19, 2012 18:09
ProfitTrain Postbox script
-- The following is an AppleScript function ProfitTrain will call when you choose "Email Client..."
-- under an invoice. Before using the built in AppleScript ProfitTrain will look for
-- this user AppleScript file at:
-- /Users/[you]/Library/Application Support/ProfitTrain/email_invoice_using_user_script.scpt
-- By edting this file you can further customize the email with different subject lines, etc.
-- and/or use an alternative email client that is not supported by Billable by default.
-- Script using Apple's Postbox
@zorn
zorn / gist:2891449
Created June 7, 2012 20:48
Need meta-programming help to DRY up this migration.
# I'm adding strip_attributes to my Rails models to help strip
# leading/trailing whitespace as well as make sure empty strings
# are saved as null in the DB. This migration does a .save! on
# all my object. I'd love to DRY up this migration as there are
# actually way more classes in the real project. Any thoughts?
class SaveAllObjectsToRunStripAttributes < ActiveRecord::Migration
class CategoryGroup < ActiveRecord::Base
strip_attributes
// SSRatingPickerScrollView.m
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat height = [_reviewTextView sizeThatFits:CGSizeMake(self.frame.size.width, 2000.0f)].height + 91.0f;
height = fmaxf(height, 191.0f);
height = height + 216.0f; // add keyboard height
self.contentSize = CGSizeMake(self.frame.size.width, height);
...
@zorn
zorn / random-expenses.rb
Created April 11, 2013 03:48
Short ruby script to generate a random expenses csv file for demo.
require 'csv'
# Our sample categories
categories = []
categories << 'Advertising'
categories << 'Bank Fees'
categories << 'Computer Hardware'
categories << 'Computer Software'
categories << 'Conferences'
categories << 'Hosting'