Skip to content

Instantly share code, notes, and snippets.

View dsci's full-sized avatar

Daniel Schmidt dsci

  • Leipzig, Germany
View GitHub Profile
- (void) testNSStringFromChar
{
char * charCity = "Leipzig";
NSString *city = @"Leipzig";
NSString *cityFromChar = [NSString stringWithUTF8String:charCity];
STAssertEqualObjects(city,cityFromChar, @"cityfrom Char should be the same as city from NSString");
}
panel.items.each (item,index,length) ->
count++ if item.getValue() is ''
@dsci
dsci / rspec-syntax-cheat-sheet.rb
Created November 29, 2011 16:09 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@dsci
dsci / gist:1433824
Created December 5, 2011 14:49 — forked from jnunemaker/gist:217362
example of warden with sinatra
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@dsci
dsci / config.ru
Created December 5, 2011 14:57 — forked from thomasyip/config.ru
Sinatra + Warden & Rails + Devise Example
# /config.ru
# This file is used by Rack-based servers to start the application.
# File generated by "rails create MyApp"
# For Rails
require ::File.expand_path('../config/environment', __FILE__)
# For Sinatra
require './slim/slim.rb'
# - Make sinatra play nice
@dsci
dsci / face_detector.rb
Created December 7, 2011 17:47 — forked from pvinis/face_detector.rb
run with "macruby face_detector.rb" or "macruby face_detector.rb https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc7/304055_10150415385415891_522505890_10347873_1682210515_n.jpg?dl=1" for a photo of me with woody and buzz lightyear :p
framework 'Cocoa'
class NSColor
def toCGColor
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace)
## approach #1
# components = Array.new(4){Pointer.new(:double)}
# color_RGB.getRed(components[0],
# green: components[1],
# blue: components[2],
@dsci
dsci / base_decorator.rb
Created December 14, 2011 08:56
Decorative and building!
module DecorativeBuildr
class BaseDecorator
def initialize(decorated)
@decorated = decorated
end
def method_missing(method,*args)
@decorated.send(method,args)
end
@dsci
dsci / matchr_princess.gemspec
Created December 14, 2011 10:24
matchr_princess
Gem::Specification.new do |s|
s.name = 'matchr_princess'
s.version = '0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Daniel Schmidt'
s.email = 'dsci@code79.net'
s.summary = 'Small matcher library for rspec'
s.description = 'This goes out to the marvelous novell "A princess of mars" by Edgar Rice Burroughs.'
s.files = ['matchr_princess.rb']
@dsci
dsci / gist:1480465
Created December 15, 2011 09:13
checkout single file from git branch
git checkout <branch_from_which_file_you_want> <file_path_within_the_repo>
# Check if something has changed
git status
@dsci
dsci / gist:1496067
Created December 19, 2011 08:23
Creating and pushing tags (Git)
# Create an unsigned tag.
git tag -a vPreview19122011 -m 'preview version for product review 19th December 2011'
# List tags
git tag
# Push tags.
git push --tags
# Push a single tag