Skip to content

Instantly share code, notes, and snippets.

@ostholz
ostholz / LLDB
Created November 11, 2021 11:00
LLDB Commands
### Print swift object at address
`e -l swift -O -- 0xaddress`
### print ObjectivC object at address
`e -l objc -O -- 0xaddress`
@ostholz
ostholz / Log.swift
Last active August 24, 2023 06:17
Log function
//
// Logger.swift
//
// Created by on 24.01.20.
//
import Foundation
import os.log
public struct Logger {
@ostholz
ostholz / Handy_UIView_Autolayout
Created October 15, 2021 18:41
Handy AutoLayout Extension
extension UIView {
/**
* Set aspect ratio for self
*
* Examples: there is a view `v`
* v.aspectRatio(ratio: 2.0)
*/
public func aspectRatio(ratio: CGFloat) {
self.translatesAutoresizingMaskIntoConstraints = false
// copy from https://www.craftappco.com/blog/2018/5/30/simple-throttling-in-swift
class Throttler {
private var workItem: DispatchWorkItem = DispatchWorkItem(block: {})
private var previousRun: Date = Date.distantPast
private let queue: DispatchQueue
private let minimumDelay: TimeInterval
init(minimumDelay: TimeInterval, queue: DispatchQueue = DispatchQueue.main) {
self.minimumDelay = minimumDelay
###show all envirement variables
xcodebuild -workspace appname.xcworkspace -scheme scheme -showBuildSettings
xcodebuild -project appname.xcproj -target target -showBuildSettings
__weak __typeof(self) weakSelf = self;
[self doSomeThingWithBlock:^(void) {
if (weakSelf) {
__strong __typeof(weakSelf) strongSelf = weakSelf;
strongSelf.someProperty = someValue;
[strongSelf performSomeMethod];
}
}];
@ostholz
ostholz / rails render options
Created July 17, 2015 09:29
Rails Render Options
render :edit
render action: :edit
render "edit"
render "edit.html.erb"
render action: "edit"
render action: "edit.html.erb"
render "books/edit"
render "books/edit.html.erb"
render template: "books/edit"
render template: "books/edit.html.erb"
@ostholz
ostholz / JSF_Notiz
Created April 13, 2015 09:07
JSF Notiz
# load extern JavaScript File in xhtml
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
# loade local JavaScript File
<h:outputScript library="default" name="js/myJSFile.js"></h:outputScript>
@ostholz
ostholz / swift_standard_functions
Created October 20, 2014 10:19
Swift Standard Functions
abs(...)
advance(...)
alignof(...)
alignofValue(...)
assert(...)
bridgeFromObjectiveC(...)
bridgeFromObjectiveCUnconditional(...)
bridgeToObjectiveC(...)
bridgeToObjectiveCUnconditional(...)
c_malloc_size(...)

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }