Skip to content

Instantly share code, notes, and snippets.

@steipete
steipete / PSPDF_KEYPATH.m
Created February 17, 2017 08:38
PSPDF_KEYPATH without all the warnings
#define PSPDF_KEYPATH(object, property) (^{ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \
_Pragma("clang diagnostic ignored \"-Wimplicit-retain-self\"") \
return ((void)(NO && ((void)object.property, NO)), @#property); \
_Pragma("clang diagnostic pop") \
}())
@steipete
steipete / UIBarButtonItem+PSCBlockSupport.m
Last active October 17, 2019 11:43
Helper to call target/action from an UIBarButtonItem.
#define PSCCAssert(condition, description, ...) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wnullable-to-nonnull-conversion\"") \
NSCAssert(condition, description, ##__VA_ARGS__) \
_Pragma("clang diagnostic pop")
#define PSCWeakifyAs(object, weakName) typeof(object) __weak weakName = object
void (^psc_targetActionBlock(id target, SEL action))(id) {
// If there's no target, return an empty block.
@anthonya1999
anthonya1999 / UIDevice+Extensions.h
Last active June 15, 2018 06:54
Just some cool extensions that can tell you some more stuff about a device (all work on latest iOS version)
#import <UIKit/UIKit.h>
#include <dlfcn.h>
static const CFStringRef kMGDieID = CFSTR("DieId");
typedef NS_ENUM(NSInteger, BKSInterfaceOrientation) {
BKSInterfaceOrientationPortrait = 1,
BKSInterfaceOrientationPortraitUpsideDown = 2,
BKSInterfaceOrientationLandscapeRight = 3,
BKSInterfaceOrientationLandscapeLeft = 4
@theothermattm
theothermattm / sync-using-gitignore.sh
Created October 7, 2015 20:58
Rsync files using .gitignore
# sync everything excluding things in .gitignore
# delete anything on target not in source
# include dotfiles and symlinks, also use compression
rsync -azP --delete --filter=":- .gitignore" . my-target-host:/my/target/directory
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active April 25, 2024 04:16
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@reganjohnson
reganjohnson / gist:1f6d93c4e3d09e4d5903
Last active March 19, 2018 14:21
Set Default Text Editor as Sublime 3
First, let's create the $ subl command
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Another option is to use duti (http://duti.org / https://github.com/moretension/duti).
Run brew install duti, save a file like this as ~/.duti:
com.sublimetext.3 public.plain-text all
com.sublimetext.3 public.unix-executable all
@jedi4ever
jedi4ever / upload-to-appstore.sh
Created August 18, 2014 12:13
Command upload App/Ipa to the iTunes Connect App Store
#!/bin/bash
set -ex
# This scripts allows you to upload a binary to the iTunes Connect Store and do it for a specific app_id
# Because when you have multiple apps in status for download, xcodebuild upload will complain that multiple apps are in wait status
# Requires application loader to be installed
# See https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html
# Itunes Connect username & password
USER=bla
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
@TimMedcalf
TimMedcalf / tableViewKeyboardHandling.m
Last active July 5, 2021 12:18
The easy & reliable way of handling UITableView insets when the keyboard is shown. This works unchanged no matter where the table view is on the screen (including dealing with orientation, hierarchy, container view controllers & all devices)
/*
One of the first things someone new to iOS Development finds is that dealing with the keyboard is trickier
than they think it should be. Simply changing the scrolling extents of a UITableView (or UIScrollView, or
UICollectionView) that is partially covered by they keyboard reveals a lot about the internals of how iOS
works and highlights various "gotchas" that need to be considered.
There are various ways to know that a keyboard has been shown - but observing some specific notifications
provides a reliable way to allow you to modify your views to deal with it.