Skip to content

Instantly share code, notes, and snippets.

View dataxpress's full-sized avatar

Tim Gostony dataxpress

View GitHub Profile
@dataxpress
dataxpress / PaddedLabel.swift
Last active April 6, 2020 18:47
a uilabel with edge padding borrowed from stackoverflow
import UIKit
@IBDesignable class PaddedLabel: UILabel {
@IBInspectable var topInset: CGFloat = 0.0
@IBInspectable var bottomInset: CGFloat = 0.0
@IBInspectable var leftInset: CGFloat = 0.0
@IBInspectable var rightInset: CGFloat = 0.0
func setAllInsets(_ inset : CGFloat){
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@dataxpress
dataxpress / gist:a61f3feedb96ae6178cf
Created October 8, 2014 14:59
type of param but no name
// Playground - noun: a place where people can play
import Foundation
func myFunc(String){
// no way to access the value of the string passed in
}
// myFunc() // error
myFunc("Potato!") // works
@dataxpress
dataxpress / gist:785bf406ad0f16b9400e
Created September 2, 2014 16:00
Switching on type of object in Swift
// Playground - noun: a place where people can play
class Abc
{
}
class Def
{
}
@dataxpress
dataxpress / test.m
Created August 26, 2014 04:46
Example for returning an int from a bool
#import <Foundation/Foundation.h>
@interface SomeClass : NSObject
-(BOOL)arrayHasStuff;
-(BOOL)otherArrayHasStuff;
@property (nonatomic, retain) NSArray *array;
@property (nonatomic, retain) NSArray *otherArray;
@dataxpress
dataxpress / gist:6acf4b72f778f7b6c884
Created August 6, 2014 03:05
This makes a lot of sense to me
(lldb) po label
<SKLabelNode> name:'(null)' text:'Total: 581' fontName:'Helvetica' position:{160, 286.5}
(lldb) po label.frame
error: type of property 'frame' ('CGRect') does not match type of accessor 'frame' ('<unknown type>')
error: unsupported expression with unknown type
error: instance method 'isPaused' has incompatible result types in different translation units ('char' vs. 'BOOL' (aka 'signed char'))
error: instance method 'scene' has incompatible result types in different translation units ('id' vs. 'SKScene *')
error: instance method 'physicsBody' has incompatible result types in different translation units ('id' vs. 'SKPhysicsBody *')
error: instance method 'isHidden' has incompatible result types in different translation units ('char' vs. 'BOOL' (aka 'signed char'))
/// Syntactically correct usage: @"Hello ".append(@"World").append(@"!");
@interface NSString (horrible)
-(NSString* (^)(NSString* appendedText))append;
@end
@implementation NSString (horrible)