Skip to content

Instantly share code, notes, and snippets.

void addInternetPassword(NSString *password, NSString *account,
NSString *server, NSString *itemLabel, NSString *path,
SecProtocolType protocol, int port)
{
OSStatus err;
SecKeychainItemRef item = nil;
const char *pathUTF8 = [path UTF8String];
const char *serverUTF8 = [server UTF8String];
const char *accountUTF8 = [account UTF8String];
const char *passwordUTF8 = [password UTF8String];
SecAccessRef createAccess(NSString *accessLabel)
{
OSStatus err;
SecAccessRef access=nil;
NSArray *trustedApplications=nil;
//Make an exception list of trusted applications; that is,
// applications that are allowed to access the item without
// requiring user confirmation:
SecTrustedApplicationRef myself, someOther;
require 'osx/cocoa'
include OSX
OSX.load_bridge_support_file('/path/to/Security.bridgesupport')
def create_access(access_label)
err, myself = SecTrustedApplicationCreateFromPath(nil)
err, some_other = SecTrustedApplicationCreateFromPath('/Applications/Mail.app')
# please send me the postscript file generated by the following command
$ man -t launchctl > launchctl.ps
# please send me the output of the following commands executed in the irb that comes with Tiger
irb> require 'osx/cocoa' # => true
irb> OSX.require_framework 'PreferencePanes' # => true
irb> OSX::NSUnselectNow # => 1
require 'stringio'
require 'test/unit/testcase'
require 'minitest/unit'
class TestResult
def self.parse_failure(raw)
matches = %r{(Failure)\:\n([^\(]+)\(([^\)]+)\) \[([^\]]+)\]\:\n(.*)\n}m.match(raw)
return nil unless matches
Failure.new(matches[2], matches[3], [matches[4]], matches[5])
end
require 'bacon'
require 'mocha_standalone'
module Bacon
class AssertionCounter
def increment
Counter[:requirements] += 1
end
end
@floehopper
floehopper / gist:214172
Created October 20, 2009 10:20 — forked from technoweenie/gist:213780
how do you test algorithms?
# how do you test algorithms?
class Pythagoream < Struct.new(:a, :b)
def result
a**2 + b**2
end
end
# I prefer to "invert" the algorithm somehow
# or calculate the expected result another way.
require 'test/unit'
require 'mocha'
class MyTest < Test::Unit::TestCase
def test_me
DateTime.stubs(:now).returns(DateTime.parse("2010-01-01T10:00:00"))
index = 0
100.times { index += 1 }
assert_equal 100, index
** Execute stdlib:build
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "rbconfig.rb" -o "./rbconfig.rbo"
/Users/jamesmead/ThirdParty/MacRuby/lib/yaml.rb:9:in `<main>': no such file to load -- libyaml (LoadError)
from /Users/jamesmead/ThirdParty/MacRuby/lib/rubygems/config_file.rb:7:in `<main>'
from /Users/jamesmead/ThirdParty/MacRuby/lib/rubygems.rb:878:in `<main>'
rake aborted!
Command failed with status (1): [./miniruby -I. -I./lib bin/rubyc --interna...]
/usr/local/ruby-1.8.6-p287/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:995:in `sh'
/usr/local/ruby-1.8.6-p287/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `call'
/usr/local/ruby-1.8.6-p287/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `sh'
it 'should destroy the ear if the user is already a member' do
ci = Factory.create(:valid_contact_import)
ear = Factory.create(:valid_emailed_association_request)
user = Factory.create(:valid_user)
ci.user = user
ci.emailed_association_requests << ear
User.stubs(:find_by_email).returns(Factory.build(:valid_user))
ba = Factory.build(:valid_business_association)
ba.stubs(:save!)
BusinessAssociation.stubs(:new).returns(ba)