Skip to content

Instantly share code, notes, and snippets.

@johanhar
johanhar / gettype.swift
Created March 23, 2016 10:02
Meta types
func getType<T>(type: T.Type) -> T.Type {
return type.self
}
class Foo {
required init() { }
}
let MyType = getType(Foo)
let myFoo = MyType.init()
@johanhar
johanhar / uic9183aztecbarcodedecoding.m
Last active November 13, 2017 07:33
uic-918-3 aztec barcode decoding ios objective-c
// add this method to ZXAztecDecoder.m (ZXingObjC)
+ (NSString *)UIC9183TicketId:(ZXBoolArray *)correctedBits
{
NSMutableData *bytes = [[NSMutableData alloc] init];
int endIndex = (int)correctedBits.length;
ZXAztecTable latchTable = ZXAztecTableUpper; // table most recently latched to
ZXAztecTable shiftTable = ZXAztecTableUpper; // table to use for the next read
@johanhar
johanhar / ioskeyboard.swift
Last active March 8, 2016 15:14
iOS keyboard scrollview tableview
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
registerKeyboardNotifications()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
unregisterKeyboardNotifications()
}
- (void)viewDidLoad
{
NSLog(@"view did load");
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//NSLog(@"View Controller Container. Width: %f, Height: %f", self.container.frame.size.width, self.container.frame.size.height);
}
template: something,
events: {
"click #foto-modal-produkt-lagre": "saveProdukt",
"click #foto-modal-produkt-avbryt": "close",
"click #foto-modal-produkt-slett": "deleteProdukt",
"keyup #produkt-edit-modal-template:input" : "inputPressed"
},
inputPressed: function(e) {
console.log("pressed") // never happens :(
public function __get($name, $value) {
if ($name == "tariff" && get_called_class() != get_class($this)) {
return (intval($this->$name) / 100);
} else if ($name == "durationType" && get_called_class() != get_class($this)) {
} else {
return $this->$name;
}
}