Skip to content

Instantly share code, notes, and snippets.

// numi script
// screen width in UIKit points
width_p = 414
// screen height in UIKit points
height_p = 896
// screen diagonal in inches
diagonal_i = 6.5
@maniak-dobrii
maniak-dobrii / gist:f718db391721ccc844a928ccdb685fa6
Created September 8, 2016 13:19
UIFontWeight constants in iOS 9.3
NSLog(@"UIFontWeightUltraLight = %@", @(UIFontWeightUltraLight));
NSLog(@"UIFontWeightThin = %@", @(UIFontWeightThin));
NSLog(@"UIFontWeightLight = %@", @(UIFontWeightLight));
NSLog(@"UIFontWeightRegular = %@", @(UIFontWeightRegular));
NSLog(@"UIFontWeightMedium = %@", @(UIFontWeightMedium));
NSLog(@"UIFontWeightSemibold = %@", @(UIFontWeightSemibold));
NSLog(@"UIFontWeightBold = %@", @(UIFontWeightBold));
NSLog(@"UIFontWeightHeavy = %@", @(UIFontWeightHeavy));
NSLog(@"UIFontWeightBlack = %@", @(UIFontWeightBlack));
NSLog(@"all supported localizations: %@", [[NSBundle mainBundle] localizations]);
NSLog(@"development localization: %@", [[NSBundle mainBundle] developmentLocalization]);
NSLog(@"preffered languages: %@", [NSLocale preferredLanguages]);
NSLog(@"");
NSLog(@"preffered localizations(most suitable): %@", [[NSBundle mainBundle] preferredLocalizations]);
NSLocale *activeLocale = [NSLocale localeWithLocaleIdentifier:[[[NSBundle mainBundle] preferredLocalizations] firstObject]];
NSLog(@"active locale: %@", activeLocale.localeIdentifier);
@maniak-dobrii
maniak-dobrii / gist:5239b3a1bd313114c3e1
Created September 25, 2014 13:02
Get focused (closest to the picker's vertical center) row in UIPickerView
/**
* Returns focused (closest to the picker's vertical center) row.
*
* @param picker picker which rows should be inspected
* @param row center row to search around (row +- some_value) will be evaluated
* @param component component in picker to be inspected
*
* @note This approach requires use of -pickerView:viewForRow:forComponent:reusingView: for row creation, if you
* only use -pickerView:titleForRow:forComponent:, it won't be able to get views via -viewForRow:forComponent:
* and inspect them.
@maniak-dobrii
maniak-dobrii / Unescape unicode string
Last active August 29, 2015 13:56
Unescape unicode string for debug purposes. Convert \Uabcd, \\Uabcd, \uabcd, \\uabcd to it's symbol representation (fe: "\\U002E\\U002C" to ".,"). Useful for NSLog'ing NSManagedObjects.
/*
This one may be not optimal, first solution, but helps with NSLogs.
So you can have:
NSManagedObject *object = ...
// No \\Uabcd's in log
NSLog(@"object = %@", [[object debugDescription] unicodeUnescape]);
*/
#!/usr/bin/python
# fix-xcode
# Rob Napier <robnapier@gmail.com>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs: