Skip to content

Instantly share code, notes, and snippets.

View levi's full-sized avatar

Levi McCallum levi

View GitHub Profile
//
// CurrencyDelegate.swift
// TextFieldDelegate
//
// Created by Timothy Isenman on 12/10/17.
// Copyright © 2017 Timothy Isenman. All rights reserved.
//
import Foundation
import UIKit
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if let digit = Int(string) {
amount = amount * 10 + digit
textField.text = String(describing: currencyAmount()!)
} else if string == "" {
amount = amount / 10
textField.text = String(describing: currencyAmount()!)
}
@levi
levi / gist:3876797
Created October 12, 2012 01:16 — forked from cameronmcefee/gist:2641743
Font Configuration File
# Font Squirrel Font-face Generator Configuration File
# Upload this file to the generator to recreate the settings
# you used to create these fonts.
{"mode":"expert","formats":["ttf","woff","eot","svg"],"tt_instructor":"default","options_subset":"advanced","subset_custom":"","subset_custom_range":"f000-f073,f200-f273","emsquare":"2048","spacing_adjustment":"0","rememberme":"Y"}
@levi
levi / Stately ViewState support for Backbone.js Views.js
Created August 17, 2012 19:22 — forked from camwest/Stately ViewState support for Backbone.js Views
A simple implementation of view states for Backbone.js
// (c) 2010 Cameron Westland, Big Bang Technology Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://bigbangtechnology.github.com/stately
/**
Example:
var MyView = Backbone.View.extend(Stately).extend({
states: {
EDITING: "editing",
@levi
levi / gist:2323328
Created April 6, 2012 21:55 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p125
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2323328)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@levi
levi / rspec_mock_rails3_chained_queries.rb
Created October 30, 2010 01:32
A really smelly, but working way to mock test Active Record chained queries in Rails 3.
# @session and @mock_project instance variables are defined elsewhere.
before(:each) do
joins = mock(ActiveRecord::Relation)
ProjectUser.should_receive(:joins).with(:project_user_datum).and_return(joins)
joins.should_receive(:where).
with('project_user_data.project_id = :project_id', { :project_id => @mock_project }).
and_return(@mock_project)
get :index, {}, @session
end
@levi
levi / gist:315648
Created February 26, 2010 11:25
Name sc-build number with git's HEAD
module CT
module Git
def self.sha(repo)
result = `cd "#{repo}" && git log -1 --format=%H`.strip
return result =~ /^[0-9a-f]{40}$/ ? result : nil
end
end
end
config :sproutcore, :build_number => CT::Git::sha('frameworks/sproutcore')