Skip to content

Instantly share code, notes, and snippets.

@zyrx
zyrx / CopyableLabel.swift
Last active March 11, 2020 14:21
Make UILabel Copyable in Swift 3. Special thanks to Stephen Radford and his "Make UILabel Copyable in Swift" article http://stephenradford.me/make-uilabel-copyable/
//
// CopyableLabel.swift
//
// Created by Lech H. Conde on 01/11/16.
// Copyright © 2016 Mavels Software & Consulting. All rights reserved.
//
import UIKit
class CopyableLabel: UILabel {
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@jacklynrose
jacklynrose / vertical_centering_with_vfl.rb
Created October 27, 2013 10:35
This is how I managed to hack the visual format language to center a few views vertically (most other ways put them at the top and bottom, or just the top, or just the bottom). Basically what I'm doing is saying that the top margin should be less than or equal to half the portrait height minus the total height of all the views you'll be centring…
totalCombinedViewHeight = 100
Motion::Layout.new do |layout|
layout.view view
layout.subviews "state" => @state, "action" => @action
layout.metrics "margin" => 20, "height" => 40, "halfHeight" => ((view.bounds.size.height - totalCombinedViewHeight) / 2), "halfWidth" => ((view.bounds.size.width - 100) / 2)
layout.vertical "|-(<=halfHeight)-[state]-margin-[action]-(>=halfWidth)-|"
layout.horizontal "|-margin-[state]-margin-|"
layout.horizontal "|-margin-[action]-margin-|"
end
@seanlilmateus
seanlilmateus / evernote.rb
Last active January 25, 2016 19:24
ScriptingBridge with MacRuby or Rubymotion
#!/Library/RubyMotion/bin/ruby -wKUW0
# if your using MacRuby you might change this to
# => #!/usr/bin/env macruby -wKUW0
framework 'Foundation'
framework 'ScriptingBridge'
# the original is part of an arstechnica article by Ryan
# SOURCE: http://arstechnica.com/apple/2011/09/tutorial-os-x-automation-with-macruby-and-the-scripting-bridge/
# this script with get your favourite songs and create a Evernote Note # German and English
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@v1nc3ntlaw
v1nc3ntlaw / rbenv-install-system-wide.sh
Last active December 23, 2020 13:57
rbenv install ruby 1.9.3-p448 on Ubuntu 12.04 LTS
#
# Run as root
# $ bash <(curl -s https://raw.github.com/gist/1631411)
#
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl \
libssl-dev \
@jpantuso
jpantuso / osx_lion_rail_setup.md
Created July 27, 2011 19:51
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, rails, and MySQL