Skip to content

Instantly share code, notes, and snippets.

View davemess's full-sized avatar
💻

David Messing davemess

💻
View GitHub Profile
+ (void)replaceSelector:(SEL)originalSelector withSelector:(SEL)swizzledSelector forClass:(Class)class
{
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
@davemess
davemess / Property Names
Created September 12, 2014 17:26
Returns an array containing NSStrings of all property names.
#import <objc/runtime.h>
- (NSArray *)allPropertyNames
{
unsigned count;
objc_property_t *properties = class_copyPropertyList([self class], &count);
NSMutableArray *rv = [NSMutableArray array];
unsigned i;
class AsynchronousOperation: NSOperation {
override var asynchronous: Bool {
return true
}
private var _executing = false
override var executing: Bool {
get {
return _executing
* Delete the section referring to the submodule from the .gitmodules file
* Stage the changes via git add .gitmodules
* Delete the relevant section of the submodule from .git/config.
* Run git rm --cached path_to_submodule (no trailing slash)
* Run rm -rf .git/modules/path_to_submodule
* Commit the changes with `git commit -m "Removed submodule "
* Delete the now untracked submodule files rm -rf path_to_submodule
@davemess
davemess / Bash profile
Created July 14, 2018 14:50
A starter for bash profile
# Configure Terminal
export CLICOLOR=1
export LSCOLORS=GxExBxBxFxegedabagacad
# Git http://bash-completion.alioth.debian.org/
source ~/.git-completion.bash
# Aliases
alias whichip="ipconfig getifaddr en1"
${COMMAND} > /dev/null 2>&1 &
Eg. Redirect to different terminal:
${COMMAND} > /dev/ttys008 2>&1 &
@davemess
davemess / Swift Karatsuba Multiplication
Last active August 15, 2018 18:09
Implementation of Karatsuba Multiplication in Swift
import Foundation
precedencegroup ExponentiativePrecedence {
higherThan: MultiplicationPrecedence
lowerThan: BitwiseShiftPrecedence
associativity: left
}
infix operator ^^: ExponentiativePrecedence
func ^^ (radix: Double, power: Double) -> Double {
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->