This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// How to use | |
// Drag an UIView to storyboard, set constraints. | |
// Set the height constraint priority to less than 1000. | |
// The view will override that to half pixel. | |
class HairlineView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zip/zip' | |
# zip files | |
Dir.chdir(parent_directory) | |
zipfile = directory + ".zip" | |
return false if File.exist?(zipfile) | |
Zip::ZipFile::open(zipfile, true) do |zf| | |
Dir["#{directory}/**/*"].each { |f| zf.add(f, f) } | |
zf.close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Photo < ActiveRecord::Base | |
has_attachment options_for_attachment_fu | |
after_attachment_saved do |foto| | |
# delete original file for disk space saving | |
FileUtils.rm foto.full_filename if foto.parent.nil? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# fetch hosts from amazon EC2 meta-data | |
# | |
# Based on http://dysinger.net/2008/10/13/using-amazon-ec2-metadata-as-a-simple-dns | |
# | |
%w(logger optparse rubygems right_aws resolv pp).each { |l| require l } | |
LOGGER = Logger.new("/var/log/fetch_hosts.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return date for internet date string (RFC822 or RFC3339) | |
// - RFC822 http://www.ietf.org/rfc/rfc822.txt | |
// - RFC3339 http://www.ietf.org/rfc/rfc3339.txt | |
// - Good QA on internet dates: http://developer.apple.com/iphone/library/qa/qa2010/qa1480.html | |
// - Cocoa date formatting: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns | |
+ (NSDate *)dateFromInternetDateTimeString:(NSString *)dateString { | |
// Setup Date & Formatter | |
NSDate *date = nil; | |
static NSDateFormatter *formatter = nil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework 'Cocoa' | |
require 'net/https' | |
class SomeOperation < NSOperation | |
def main | |
http = Net::HTTP.new("mail.google.com", 443) | |
http.use_ssl = true | |
response = nil | |
http.start do |h| | |
req = Net::HTTP::Get.new("/mail/feed/atom") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function() { | |
$.cookie('tz', (new Date()).getTimezoneOffset()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ macruby_deploy --compile --embed --bs Gmail\ Notifr.app | |
*** Deployment started | |
*** Embedding MacRuby.framework | |
*** Embed BridgeSupport system files | |
*** Fix install path of binaries | |
*** Fix identification name of libmacruby | |
/usr/bin/otool: can't open file: Gmail (No such file or directory) | |
/usr/bin/otool: can't open file: Notifr.app/Contents/Frameworks/MacRuby.framework/Versions/Current/usr/lib/ruby/site_ruby/1.9.2/universal-darwin10.0/bigdecimal.bundle (No such file or directory) | |
Error when executing `/usr/bin/otool -L Gmail Notifr.app/Contents/Frameworks/MacRuby.framework/Versions/Current/usr/lib/ruby/site_ruby/1.9.2/universal-darwin10.0/bigdecimal.bundle' |
OlderNewer