Skip to content

Instantly share code, notes, and snippets.

View mickeyl's full-sized avatar
🏠
Working from home

Dr. Mickey Lauer mickeyl

🏠
Working from home
View GitHub Profile
@mickeyl
mickeyl / ArduinoCompat.hpp
Created May 13, 2023 12:31
Arduino => ESP-IDF Compatibility Header
#ifndef ESPENLAUB_ARDUINO_COMPAT_H
#define ESPENLAUB_ARDUINO_COMPAT_H
#pragma once
#include "driver/gpio.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
using byte = uint8_t;
@mickeyl
mickeyl / UIImage+PSPDFKitAdditions.m
Created September 24, 2020 18:50 — forked from steipete/UIImage+PSPDFKitAdditions.m
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@mickeyl
mickeyl / SomeUITableViewCell.m
Last active August 20, 2016 11:25
Work around a crash in UITableView when changing layout during scrolling
-(void)triggerRelayoutIfNecessary
{
[_activityIndicator stopAnimating];
float newHeight = [self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
if ( newHeight != _lastHeight )
{
UITableView* tv = (UITableView*)[self LT_findFirstSuperviewOfClass:UITableView.class];
if ( tv.isDragging || tv.isDecelerating )
{
@mickeyl
mickeyl / NSString+Extensions.h
Created March 11, 2016 10:06
A taste of Python in Objective-C
@implementation NSString (IndexedSubscripting)
-(NSString*)objectAtIndexedSubscript:(NSInteger)index
{
NSRange range = NSMakeRange( index < 0 ? self.length + index: index, 1 );
return [self substringWithRange:range];
}
@end
@mickeyl
mickeyl / LTLabel.m
Last active March 11, 2016 10:24
Poor man's UIStackView :)
-(CGSize)intrinsicContentSize
{
if ( _zeroIntrinsicContentSizeIfHidden && self.hidden )
{
return CGSizeZero;
}
return [super intrinsicContentSize];
}