Skip to content

Instantly share code, notes, and snippets.

View SpectralDragon's full-sized avatar
🎯
Focusing

Vladislav Prusakov SpectralDragon

🎯
Focusing
View GitHub Profile
@j0sh
j0sh / Makefile
Created March 31, 2011 07:05
iOS static library cross-compile script.
# iOS builds for ARMv7 and simulator i386.
# Assumes any dependencies are in a local folder called libs and
# headers in a local folder called headers.
# Dependencies should already have been compiled for the target arch.
PROJ=untitled
ifeq ($(IOS), 1)
ARCH=armv7
DEVICE=OS
CC_FLAGS=-arch $(ARCH)
@tecoholic
tecoholic / gitpatch.sh
Created June 7, 2011 05:43
Creating Patches in GIT
#To visualize branches:
git branch
#To create a new branch:
git branch testbranch
#To change to created branch:
git checkout testbranch
#Track new files:
@steventroughtonsmith
steventroughtonsmith / gist:6763213
Created September 30, 2013 12:39
Non-opaque application windows in iOS 7, with optional blur. Shows the user's wallpaper under the app, with Parallax if supported.
typedef enum _UIBackgroundStyle {
UIBackgroundStyleDefault,
UIBackgroundStyleTransparent,
UIBackgroundStyleLightBlur,
UIBackgroundStyleDarkBlur,
UIBackgroundStyleDarkTranslucent
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)
-(void)_setBackgroundStyle:(UIBackgroundStyle)style;
@quietcricket
quietcricket / Global keyboard hook for OSX
Created January 8, 2014 07:42
OSX global keyboard hook. Requires root privileges.
// alterkeys.c
// http://osxbook.com
//
// Complile using the following command line:
// gcc -Wall -o alterkeys alterkeys.c -framework ApplicationServices
//
// You need superuser privileges to create the event tap, unless accessibility
// is enabled. To do so, select the "Enable access for assistive devices"
// checkbox in the Universal Access system preference pane.
# ~/.lldbinit-Xcode
# Apple private methods
command regex ivars 's/(.+)/po [%1 _ivarDescription]/'
command regex methods 's/(.+)/po [%1 _methodDescription]/'
command regex shortmethods 's/(.+)/po [%1 _shortMethodDescription]/'
command regex nextviewcontroller 's/(.+)/po [%1 _nextViewControllerInResponderChain]/'
command alias nextvc nextviewcontroller
# Convenience
@sharplet
sharplet / rake.log
Last active September 12, 2022 12:24
Building a Swift framework, then building and running Quick specs, *without Xcode*
# View on GitHub: https://github.com/sharplet/Switch
# Try it yourself: git clone https://github.com/sharplet/Switch.git && cd Switch && rake
$ rake
mkdir -p Build
mkdir -p Build/Switch.framework
mkdir -p Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule
ln -sf A Build/Switch.framework/Versions/Current
ln -sf Versions/Current/Modules Build/Switch.framework/Modules
ln -sf Versions/Current/Switch Build/Switch.framework/Switch
xcrun -sdk macosx swiftc -module-name Switch -emit-library -o Build/Switch.framework/Versions/Current/Switch -- Source/Array+Ext.swift Source/Option.swift Source/ParseResult.swift Source/Parser.swift Source/String+Ext.swift
@zacwest
zacwest / ios-font-sizes.swift
Last active July 17, 2024 21:39
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@JonFir
JonFir / DeviceModel.swift
Created March 29, 2016 04:26
Get device model in Swift
import UIKit
public extension UIDevice {
var modelName: String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8 where value != 0 else { return identifier }
NSMutableArray *commands = [[NSMutableArray alloc] init];
NSString *characters = @"`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./";
for (NSInteger i = 0; i < characters.length; i++) {
NSString *input = [characters substringWithRange:NSMakeRange(i, 1)];
/* Caps Lock */
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierAlphaShift action:@selector(handleCommand:)]];
/* Shift */
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierShift action:@selector(handleCommand:)]];
/* Control */
@moflo
moflo / MFBadgeButton
Created February 3, 2017 17:59
Swift add badge to UIButton - MFBadgeButton.swift
class MFBadgeButton : UIButton {
var badgeValue : String! = "" {
didSet {
self.layoutSubviews()
}
}
override init(frame :CGRect) {