Skip to content

Instantly share code, notes, and snippets.

View scottymac's full-sized avatar

Scott McMillin scottymac

View GitHub Profile

Keybase proof

I hereby claim:

  • I am scottymac on github.
  • I am scottymac (https://keybase.io/scottymac) on keybase.
  • I have a public key whose fingerprint is 36A4 DC4D 2E93 A124 8936 3E78 3BEA 3029 2C1D 2805

To claim this, I am signing this object:

class UITextView #(Extensions) https://gist.github.com/brentsimmons/5810992/
def stringCharacterIsAllowedAsPartOfLink(s)
if (s == nil || s.length < 1)
return false
end
ch = s.characterAtIndex(0)
if NSCharacterSet.whitespaceAndNewlineCharacterSet.characterIsMember(ch)
return false
end
//
// XDSpinner.h
// Sparrow 2.X
//
// Created by Shilo White on 8/17/13.
// Copyright (c) 2013 XIDA Design & Technik. All rights reserved.
//
#import "SPDisplayObjectContainer.h"
@mixin retina($ratio: 1.5) {
$dpi: $ratio * 96;
$opera-ratio: $ratio * 100;
@media only screen and (-webkit-min-device-pixel-ratio: #{$ratio}),
only screen and ( -o-min-device-pixel-ratio: '#{$opera-ratio}/100'),
only screen and ( min-resolution: #{$dpi}dpi),
only screen and ( min-resolution: #{$ratio}dppx) {
@content;
}
if 'createTouch' of document
ignore = /:hover\b/
try
for stylesheet in document.styleSheets
idxs = []
# detect hover rules
for rule, idx in stylesheet.cssRules
if rule.type is CSSRule.STYLE_RULE and ignore.test(rule.selectorText)
idxs.unshift idx
class SubmitButton < UIButton
def self.make(params={})
# return instance of SubmitButton (or any subclass)
@submitButton = self.buttonWithType(UIButtonTypeRoundedRect)
@submitButton.frame = params[:frame]
# defaults
@submitButton.titleLabel.font = UIFont.systemFontOfSize(14)
@submitButton.titleLabel.text = "Submit"
@submitButton.titleLabel.backgroundColor = UIColor.grayColor
@scottymac
scottymac / Array_to_enum.rb
Created July 2, 2012 02:24
Array#to_enum
class Array
def to_enum
Array.new(self.size, &lambda { |n| self[n].is_a?(Hash) ? self[n] : {:"#{self[n]}" => n}} ).inject({}) {|m, w| m.merge!(w) }
end
end
FRUIT = [:apple, :orange, :strawberry].to_enum
puts FRUIT[:apple]
>> 0
@scottymac
scottymac / gist:2512993
Created April 27, 2012 20:49
Bootstrap Variables
// Variables.less
// Variables to customize the look and feel of Bootstrap
// -----------------------------------------------------
// GLOBAL VALUES
// --------------------------------------------------
@scottymac
scottymac / hack.sh
Created March 31, 2012 22:37 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@scottymac
scottymac / gist:1810536
Created February 12, 2012 20:01
Custom validators for jQuery Tools
// custom validators
// generic validator for required input fields to work with validator() & [placeholder]
$.tools.validator.fn("input[required]", "Please complete this mandatory field.", function(input, value) {
var pass;
if ((value == "") || (value == $(input).attr("placeholder"))) {
$(input).addClass("invalid");
pass = false;
} else {
$(input).removeClass("invalid");