Get it from the App Store.
In XCode's Preferences > Downloads you can install command line tools.
def del_dup | |
for a in Attachment.all | |
dup = Attachment.find(:all, :conditions=>{:filename => a.filename, :filesize=>a.filesize}) | |
if dup.count > 1 | |
puts "Duplicated Attachment found! Start purging..." | |
puts "item # #{a.id} #{a.filename} (#{a.filesize}) got #{dup.count} duplicated items." | |
for as in dup[1..-1] | |
puts "Deleting #{as.id}..." | |
as.delete_from_disk | |
as.destroy |
#!/usr/bin/env ruby | |
# Xcode auto-versioning script for Subversion by Axel Andersson | |
# Updated for git by Marcus S. Zarra and Matt Long | |
# Converted to ruby by Abizer Nasir | |
# Appends the git sha to the version number set in Xcode. | |
# see http://www.stompy.org/2008/08/14/xcode-and-git-another-build-script/ for more details | |
# These are the common places where git is installed. | |
# Change this if your path isn't here |
#!/usr/bin/env ruby | |
plist = "/Users/cat/projects/proj/proj-Info.plist" | |
version = `git rev-parse --short HEAD` | |
`/usr/libexec/Plistbuddy -c "Set CFBundleVersion #{version}" #{plist}` |
#!/bin/sh | |
# Setup dynamic dns on Route 53 for aws ec2 (CNAME) | |
# | |
# Modified from Johan Lindh's script | |
# | |
# Script requirements: | |
# | |
# wget | |
# grep |
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'rubygems' | |
require 'aws-sdk' | |
config = {:access_key_id => '', | |
:secret_access_key => ''} | |
AWS.config(config) | |
ec2 = AWS::EC2.new | |
ec2 = ec2.regions['ap-northeast-1'] |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
instance_id = `wget "http://169.254.169.254/latest/meta-data/instance-id" -o /dev/null -O /dev/stdout` | |
config = {:access_key_id => '', | |
:secret_access_key => ''} | |
AWS.config(config) | |
ec2 = AWS::EC2.new | |
ec2 = ec2.regions['ap-northeast-1'] |
/* | |
example of c equivalent to php | |
<?php | |
// Create the keypair | |
$res=openssl_pkey_new(); | |
// Get private key | |
openssl_pkey_export($res, $privkey); | |
// Get public key |
Display local UIImage on UIWebview | |
[[NSBundle mainBundle] bundleURL] | |
[[NSBundle mainBundle] URLForResource:@"myimage" withExtension:@"png"] | |
#import "NSString+DataURI.h" | |
#import "NSData+Base64.h" | |
... | |
-(void)webViewDidFinishLoad:(UIWebView *)webView |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'active_support' | |
merged = `cd /home/m/git/repositories/miiicasa.git && git branch --merged master | grep -v master` | |
not_merged_cmd = 'cd /home/m/git/repositories/miiicasa.git && git branch | grep -v master | grep -v support | grep -v qa' | |
for line in merged.split("\n") | |
not_merged_cmd += '| grep -v ' + line | |
end | |
puts "This is a regular check of miiiCasa.git branches\n" |