Skip to content

Instantly share code, notes, and snippets.

View rodionovd's full-sized avatar
🗿
I'm slow

Dmitry Rodionov rodionovd

🗿
I'm slow
View GitHub Profile
@CodaFi
CodaFi / alltheflags.md
Last active June 2, 2024 17:09
Every Option and Flag /swift (1.2) Accepts Ever

#Every Single Option Under The Sun

  • optimization level options
  • automatic crashing options
  • debug info options
  • swift internal options
  • swift debug/development internal options
  • linker-specific options
  • mode options
@AliSoftware
AliSoftware / Generics-Macros.h
Last active December 11, 2020 17:18
ObjCGenerics
// Allow to use generics even if not supported yet
#if __has_feature(objc_generics)
#define NSArrayOf(x) NSArray<x>
#define NSMutableArrayOf(x) NSMutableArray<x>
#define NSDictionaryOf(x,y) NSDictionary<x, y>
#define NSMutableDictionaryOf(x, y) NSMutableDictionary<x, y>
#define NSSetOf(x) NSSet<x>
#define NSMutableSetOf(x) NSMutableSet<x>
#else
#define NSArrayOf(x) NSArray
@nschum
nschum / Precondition.swift
Created July 10, 2015 19:06
Testing precondition (or assert) in Swift
/// Our custom drop-in replacement `precondition`.
///
/// This will call Swift's `precondition` by default (and terminate the program).
/// But it can be changed at runtime to be tested instead of terminating.
func precondition(@autoclosure condition: () -> Bool, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UWord = __LINE__) {
preconditionClosure(condition(), message(), file, line)
}
/// The actual function called by our custom `precondition`.
var preconditionClosure: (Bool, String, StaticString, UWord) -> () = defaultPreconditionClosure
@antons
antons / xcode-plugin-update.sh
Last active May 4, 2016 20:04
Script to make all your Xcode plugins “compatible” with currently selected version of Xcode.
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
xcode-plugin-add-compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
xcode-plugin-has-compatibility() {
You can specify the underlying name for a C function the linker/compiler should actually use. If you use an existing
function's name, it will just let you refer to it with your prototype's name. If you define the function, it'll give
it that name. It even complains if a function of that name already exists. Tested with clang on a Mac, but AFAIK also
works in GCC. You can even use special characters in your function names, like you can do in assembly.
@evantoli
evantoli / GitConfigHttpProxy.md
Last active June 5, 2024 03:44
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@steipete
steipete / gist:12c73d1b4dc1e933e15d
Last active June 26, 2019 22:48
Since some asked, these are the specs for my new hell machine. (https://twitter.com/steipete/status/697675524286627840). I got most of the parts on Amazon, keep an eye out for their warehouse deals, great savings for usually just damaged boxes.
Fractal Design Define S Black
Corsair CP-9020094-EU RMX Serie RM1000X ATX/EPS (if you don't do SLI 850W is good enough)
Asus ROG Maximus VIII Hero Gaming Mainboard
Corsair CMK32GX4M4A2400C14 Vengeance LPX 32GB
Intel Core™ i7-6700K
Noctua NH-D15S
Samsung Basic MZ-7KE1T0BW 850 Pro SSD (no space for an PCI-E version...)
Western Digital WD40EZRX Caviar Green 4TB (optional)
@Catfish-Man
Catfish-Man / sethack.m
Created March 11, 2016 06:21
Demonstrating the trick of using stack-allocated mimics and sets for lookup tables instead of heap allocated keys and dictionaries
// Compile with clang -framework Foundation sethack.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
/*
CFHashBytes from http://www.opensource.apple.com/source/CF/CF-1153.18/CFUtilities.c
*/
#define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1;
@pilky
pilky / SourceListTableCellView.swift
Created July 6, 2020 19:06
A source list cell that correct colours the label text of a drag image when selected
class SourceListTableCellView: NSTableCellView {
override var draggingImageComponents: [NSDraggingImageComponent] {
let components = super.draggingImageComponents
guard
self.backgroundStyle == .emphasized, //emphasized = selected
let textField = self.textField,
let newStyle = textField.attributedStringValue.mutableCopy() as? NSMutableAttributedString,
let labelIndex = components.firstIndex(where: { $0.key == .label })
else {
return components
@saagarjha
saagarjha / swizzler.h
Last active December 25, 2023 18:06
Type-safe, RAII swizzler for Objective-C++
// Example usage:
// Swizzler<NSString *, NSDateFormatter *, NSDate *> NSDateFormatter_stringFromDate_ {
// NSDateFormatter.class, @selector(stringFromDate:), [&](auto self, auto date) {
// if ([NSCalendar.currentCalendar components:NSCalendarUnitWeekday fromDate:date].weekday == 4) {
// return @"It Is Wednesday My Dudes";
// } else {
// return NSDateFormatter_stringFromDate_(self, date);
// }
// }
// };