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
# source code from internet & Why's (Poignant) Guide to Ruby | |
# fibonacci by ruby one liners | |
fibonacci = Hash.new { |h, k| x < 2 ? k : h[k] = h[k-1] + h[k-2] } | |
# print something several times | |
5.times { print "Odelay!" } | |
# unless | |
exit unless "restaurant".include? "aura" |
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
# scannerController.rb | |
def session(session, didScan:result) | |
if (!result.nil?) | |
if (!(@result==result)) | |
@result = result.copy | |
@scannerSession.pause; | |
Dispatch::Queue.main.async{ | |
@overlayController.scanner(self, resultFound:result) |
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
# example | |
platform: iOS | |
pod 'Moodstocks-iOS-SDK', '~> 3.5' |
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
def gen_bridge_metadata(headers, bs_file) | |
sdk_path = self.sdk('iPhoneSimulator') | |
includes = headers.map { |header| "-I'#{File.dirname(header)}'" }.uniq | |
a = sdk_version.scan(/(\d+)\.(\d+)/)[0] | |
sdk_version_headers = ((a[0].to_i * 10000) + (a[1].to_i * 100)).to_s | |
extra_flags = OSX_VERSION >= 10.7 ? '--no-64-bit' : '' | |
sh "RUBYOPT='' /usr/bin/gen_bridge_metadata --format complete #{extra_flags} --cflags \"-isysroot #{sdk_path} -miphoneos-version-min=#{sdk_version} -D__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__=#{sdk_version_headers} -I. #{includes.join(' ')}\" #{headers.map { |x| "\"#{x}\"" }.join(' ')} -o \"#{bs_file}\"" | |
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
# Example of delegation in RubyMotion | |
class MsActivityView < UIView | |
attr_accessor :delegate | |
def initWithFrame(frame) | |
super | |
#... | |
@cancelButton = UIButton.alloc.init | |
@cancelButton.addTarget( | |
self, | |
action: :cancel, |
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
pod 'yourpod', :podspec => "/path/to/your/podsepc" | |
# OR | |
pod "yourpod", :local => "/path/to/your/repo" |
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
#if MS_SDK_REQUIREMENTS | |
/** | |
* Open the scanner and connect it to the database file | |
*/ | |
- (BOOL)open:(NSError **)error; | |
/** | |
* Close the scanner and disconnect it from the database file | |
*/ |
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
Objective-C stub for message `open:' type `c@:^@' not precompiled. Make sure you properly link with the framework or library that defines this message. |
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
/* Declare an orientation delegate protocol somewhere */ | |
@protocol SomeOrientationDelegate <NSObject> | |
(NSUInteger)supportedInterfaceOrientations; | |
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; | |
(BOOL)shouldAutorotate; | |
@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
/* MSHandler.m */ | |
// Dispatched as soon as the synchronization progresses | |
// In this method we set "shouldKeepCallback" as YES since the sync is still in progress | |
- (void)didSyncWithProgress:(NSNumber *)current total:(NSNumber *)total { | |
int percent = 100 * [current floatValue] / [total floatValue]; | |
[self.plugin returnSyncStatus:@"" | |
status:2 | |
progress:percent | |
callback:self.callback |
OlderNewer