MetaSkills.net

Git Init XCode Projects

Posted On: February 23rd, 2010 by kencollins

Here is a little ZSH function I have been using for quickly setting up new XCode apps I call tire kickers, little play and learn apps. Being able to track your learning as you go with git.

if [[ -x `which git` ]]; then
  
	function ginit_xcode () {
	  git init
	  echo "\n\n# XCode\nbuild\n*.mode1v3\n*.mode2v3\n*.nib\n*.swp\n\
*.pbxuser\n*.perspective\n*.perspectivev3\n\n# OSX\n.DS_Store\n\n\
# TextMate\n*.tm_build_errors\n\n\n" >> .gitignore
	  git add .gitignore
	  git commit -m "Ignore Xcode stuff."
	  git add .
	  git commit -m "Initial Xcode project."
	}
  
fi

The echo lines puts out a .gitignore file that will look something like this.

# XCode
build
*.mode1v3
*.mode2v3
*.nib
*.swp
*.pbxuser
*.perspective
*.perspectivev3

# OSX
.DS_Store

# TextMate
*.tm_build_errors
Tags: git, xcode

Simple Script/Console Function

Posted On: February 6th, 2010 by kencollins

This is something simple I worked up today for my ZSH profile that let's me keep my simple sc alias and have it work with all versions of rails. If you did not know, all the script files in rails 3 are gone and the new all-in-one rails executable does all the heavy lifting. This little function even passes down all the arguments too.

sc () {
  if [ -f ./script/rails ]; then 
    rails console $argv
  else
    ./script/console $argv
  fi
}

One other thing, the way rails uses IRB is different now. I had to change my ~/.irbrc file to look like this below to get my simple prompt and history back. IMPORTANT NOTE: In order for this to work, you have to apply this 2 line patch to your save-history.rb file. Worked like a champ for me.

1
2
3
4
5
6
7
8
9
10

# IRB history patch <http://redmine.ruby-lang.org/issues/show/1556>

require 'irb/completion'
require 'irb/ext/save-history'

IRB.conf[:USE_READLINE] = true
IRB.conf[:SAVE_HISTORY] = 500
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb.hist"
IRB.conf[:PROMPT_MODE] = :SIMPLE
Tags:

Unobtrusive JS In Rails 3 With Prototype

Posted On: January 29th, 2010 by kencollins

Are you bleeding on the edge of rails 3 and need to shim up some unobtrusive JavaScript to work with your link_to code that uses a destructive :method option? I did today and here is what I did to solve it. If you are unfamiliar with the problem, and what has been happening in rails 3 with UJS, check out Piotr Solnica's blog for a good run down. Or you can check out the simple code block below.

Tags:

Quickie.js - Prototype wrapper for QuickTime

Posted On: January 24th, 2010 by kencollins

As some of you know, I am in the last steps of announcing my first iPhone application. We all know that every good iPhone application has a great marketing website with a screen cast. I myself was heavily inspired by the Tapbots Convertbot website while building my own and wanted a good way of embedding the screen cast. I think the last time I did an object/embed tag was god... around 2003 or something, seriously.

Rails Button Links In Embedded Forms

Posted On: January 5th, 2010 by kencollins

This is one I have had sitting around for almost 3 years now in my toolbox and thought I would share. Have you ever had complicated rails forms and needed simple form buttons that just took you to a simple link? Were you bitten by the button_to helper code because it generates another form inside of a form? If so, here is a simple rails view helper I made that creates simple button links for embedded forms by making an input with a javascript function. Tag soup you ask, hell yeah, but worth if if you need it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

def button_to_link(name, link, options={})
  confirm_option = options.delete(:confirm)
  popup_option = options.delete(:popup)
  link_function = popup_option ? redirect_function(link,:new_window => true) : redirect_function(link)
  link_function = "if (confirm('#{escape_javascript(confirm_option)}')) { #{link_function}; }" if confirm_option
  button_to_function name, link_function, options
end

def redirect_function(location, options={})
  location = location.is_a?(String) ? location : url_for(location)
  if options[:new_window]
    %|window.open('#{location}')|
  else
    %|{window.location.href='#{location}'}|
  end
end
Tags: form, rails, ruby

Authenticated S3 GETs For Private Objects Using Paperclip

Posted On: November 23rd, 2009 by kencollins

Yea I know, I am probably the last person on earth that is just getting around to using Paperclip. To be honest, most of my file upload code was written way before Paperclip or even AttachementFu was ever conceived. And frankly, I do not do much social app coding on the side - so the need never came up. But that changed recently and I wanted a really really good way of leveraging AWS::S3 storage with the best local app security while maintaining tight control over the files.

Tags: paperclip, rails, ruby, s3

Installing REE With The Snow Leopard SQL Server Stack

Posted On: October 27th, 2009 by kencollins

Today I noticed that Ruby Enterprise Edition 2009.10 was released and I have really been wanting to see if I could get the SQL Server adapter tested and running under it. I am really curious how the speed improvements might look and will share my results below. This article assumes that you read my previous guide titled The Ultimate OS X Snow Leopard Stack For Rails Development - x86_64, MacPorts, Ruby 1.8/1.9, SQL Server, SQLite3, MySQL & More as I will be building on top of it and referencing certain steps. So let's get down to business.

Tags: ree, ruby, sqlserver