Skip to content

Instantly share code, notes, and snippets.

View leeadkins's full-sized avatar
🎯
Focusing

Lee Adkins leeadkins

🎯
Focusing
View GitHub Profile
@cutemachine
cutemachine / gradient_view.rb
Created May 10, 2012 14:58
GradientView with RubyMotion
class GradientView < UIView
def initWithFrame(frame)
if super
rgb = CGColorSpaceCreateDeviceRGB()
ptr = Pointer.new(:float, 8)
ptr[0] = 1.0
ptr[1] = 0.0
ptr[2] = 0.0
ptr[3] = 1.0
ptr[4] = 0.0
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
require 'rubygems'
require 'nokogiri'
require 'httparty'
doc = Nokogiri(HTTParty.get('http://www.gutenberg.org/wiki/Harvard_Classics_(Bookshelf)'))
ids = doc.css('a').select{|a| a.attr('title') =~ /ebook:/ }.map do |a|
a.attr('title') =~ /ebook:(\d+)/
{:title => a.text, :id => $1 }
end.compact.uniq
.packages
*.pyc
@jakemarsh
jakemarsh / gist:592329
Created September 22, 2010 19:28
Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Your users will thank you. A lot.
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.view endEditing:YES];
}
//The endEditing: method on UIView comes to us from a category that UITextField adds to UIKit that makes the view or any subview that is the first responder resign (optionally force), that's what the "YES" bit is.
class User < ActiveRecord::Base
devise :database_authenticatable, :openid_authenticatable, :recoverable, :rememberable, :trackable, :validatable
# Handle creation of user authenticated via OpenID
def self.create_from_identity_url(identity_url)
User.new(:identity_url => identity_url)
end
# Set email as a required field from the Open ID provider
require 'rubygems'
require 'simplegeo' # gem install sg-ruby
require 'nokogiri' # gem install nokogiri
require 'typhoeus' # gem install typhoeus
require 'sinatra' # gem install sinatra
##
# About:
# This little script, sacca.rb allows you to save a gowalla user's checkins to a layer on SimpleGeo.
# it's using PubSubHubbub (Gowalla's hub is at http://hub.gowalla.com/) to subscribe to the Atom feed
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
##################################
# Edit these
set :application, "example_node_app"
set :node_file, "hello_world.js"
set :host, "ec2-174-129-114-66.compute-1.amazonaws.com"
ssh_options[:keys] = [File.join(ENV["HOME"], ".ec2", "default.pem")]
set :repository, "git://gist.github.com/479007.git"
set :branch, "master"
@gruber
gruber / Liberal Regex Pattern for All URLs
Last active May 29, 2024 00:03
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))