Skip to content

Instantly share code, notes, and snippets.

View NetguruGist's full-sized avatar

Netguru NetguruGist

View GitHub Profile
@NetguruGist
NetguruGist / hiddengems4a.m
Last active December 8, 2015 10:41
hiddengems4a objectivec
@interface NSArray<Element> : NSObject @end // objective-c class
@NetguruGist
NetguruGist / hiddengems4.swift
Created October 31, 2015 14:50
hiddengems4 swift
struct Array<Element> {} // swift struct
let swiftArray: [Int]
let objcArray = swiftArray as NSArray // no problem
@NetguruGist
NetguruGist / hiddengems5.swift
Created October 31, 2015 14:50
hiddengems5 swift
protocol _ObjectiveCBridgeable {
typealias _ObjectiveCType
static func _isBridgedToObjectiveC() -> Bool
static func _getObjectiveCType() -> Any.Type
func _bridgeToObjectiveC() -> _ObjectiveCType
static func _forceBridgeFromObjectiveC(...)
static func _conditionallyBridgeFromObjectiveC(...)
}
@NetguruGist
NetguruGist / hiddengems6.swift
Created October 31, 2015 14:50
hiddengems6 swift
@interface XYZPoint : NSObject
- (instancetype)initWithX:(double)x y:(double)y;
@property (readonly) double x;
@property (readonly) double y;
@end
@NetguruGist
NetguruGist / hiddengems6b.swift
Created October 31, 2015 14:50
hiddengems6b swift
struct Point {
let x: Double
let y: Double
}
@NetguruGist
NetguruGist / hiddengems7.swift
Created October 31, 2015 14:50
hiddengems7 swift
let objcPoint = XYZPoint(x: 3, y: 4)
let swiftPoint = objcPoint as Point // yeah
let swiftPoint = Point(x: 5, y: 6)
let objcPoint = swiftPoint as XYZPoint // hell yeah
let point: XYZPoint = Point(x: 7, y: 8) // mind = blown
@NetguruGist
NetguruGist / runloop4.1.ruby
Created October 31, 2015 14:50
runloop4.1 ruby
partOfNameChanged: Ember.observer("firstName", "lastName", function() {
console.log("[Observer]: Executing...");
})
fullName: Ember.computed("firstName", "lastName", function() {
console.log("[Computed property]: Executing...");
return (this.get("firstName") + " " + this.get("lastName"));
})
toggleName: function() {
@NetguruGist
NetguruGist / runloop4.2.ruby
Created October 31, 2015 14:50
runloop4.2 ruby
partOfNameChanged: Ember.observer("firstName", "lastName", function() {
Ember.run.once(this, "doSomeProcessing");
})
doSomeProcessing: function() {
console.log("[Observer]: Executing...");
}
fullName: Ember.computed("firstName", "lastName", function() {
console.log("[Computed property]: Executing...");
@NetguruGist
NetguruGist / runloop4.3.ruby
Created October 31, 2015 14:50
runloop4.3 ruby
this._select = this.$().select2(options);
// run ember bindings on after select2 `change` event
this._select.on("change", run.bind(this, function() {
var data = this._select.select2("data");
this.selectionChanged(data);
}));
@NetguruGist
NetguruGist / runloop4.4.ruby
Created October 31, 2015 14:50
runloop4.4 ruby
$('a').click(function() {
console.log('Doing things...');
Ember.run.schedule('actions', this, function() {
// Do more things
});
});