This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Used for swizzling on iOS 11+. UIDebuggingInformationOverlay is a subclass of UIWindow | |
@implementation UIWindow (DocsUIDebuggingInformationOverlaySwizzler) | |
- (instancetype)swizzle_basicInit { | |
return [super init]; | |
} | |
// [[UIDebuggingInformationOverlayInvokeGestureHandler mainHandler] _handleActivationGesture:(UIGestureRecognizer *)] | |
// requires a UIGestureRecognizer, as it checks the state of it. We just fake that here. | |
- (UIGestureRecognizerState)state { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UILabel (SwizzlingExamples) | |
+ (void)load | |
{ | |
SwizzleSelectorWithBlock_Begin(self, @selector(initWithFrame:)) | |
^(UILabel *self, CGRect frame) { | |
if ((self = ((id (*)(id, SEL, CGRect))_imp)(self, _cmd, frame))) { | |
// ... | |
} | |
return self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"> | |
<dict> | |
<key>name</key> | |
<string>Solarized (dark)</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
du -h / | sort -n | grep -E '^(\d+?| \d+?|\d,\d)G' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lldb | |
def GetFirstArgumentAsValue(target, frame): | |
# Note: I assume the PC is at the first instruction of the function, before the stack and registers have been modified. | |
if target.triple.startswith('x86_64'): | |
return frame.regs[0].GetChildMemberWithName("rdi") | |
elif target.triple.startswith('i386'): | |
espValue = frame.regs[0].GetChildMemberWithName("esp") | |
address = espValue.GetValueAsUnsigned() + target.addr_size | |
return espValue.CreateValueFromAddress('arg0', address, target.FindFirstType('id')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
// IB_DESIGNABLE means that the view will be | |
// rendered live in Interface Builder. | |
IB_DESIGNABLE | |
@interface MJPlaceholderView : UIView | |
// IBInspectable means that the property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Merge all contacts for easy import, ex. to google contacts. | |
set -e | |
name='_all_as_one.vcf' | |
GLOBIGNORE="${name}" # Skip the merged file. | |
cat */*.vcf *.vcf > ${name} | |
echo "Merged all contacts to ${name}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
import sublime, sublime_plugin | |
class DetectSpecialCharacters(sublime_plugin.EventListener): | |
def on_load(self, view): | |
sublime.status_message("detect_special_characters is active") | |
def on_modified(self, view): | |
# find no-break space | |
special_characters = view.find_all(u"\u00A0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get_shell | |
# | |
# This will work when called in a function and in functions calling functions etc. | |
# The function uses ps(1) to find out which shell is used. The following table | |
# shows the shell names used to distinguse them (mac osx). | |
# | |
# Shells: bash | bash | sh | ksh | csh | tcsh | zsh | | |
# Shells (ps): bash |-bash | sh | ksh | -sh | -csh | zsh | | |
# | |
get_shell() { |