Skip to content

Instantly share code, notes, and snippets.

View shergin's full-sized avatar
🤔
But... why?

Valentin Shergin shergin

🤔
But... why?
View GitHub Profile
@phatblat
phatblat / gist:b10a463ff40d9dc6a808
Created July 7, 2015 20:29
Darwin notifications in swift
// MARK: - Darwin Notifications
static private let defaultsOnPhoneChangedDarwinNotificationName = "UserDefaultsOnPhoneDidChangeDarwinNotification"
static private let defaultsOnWatchChangedDarwinNotificationName = "UserDefaultsOnWatchDidChangeDarwinNotification"
static var notificationNameForReceiving: String?
static var notificationNameForSending: String?
/// Sets up the broadcast and receiving darwin notification names as well as
/// as the necessary observer callbacks.
@ohad7
ohad7 / Tweaks.swift
Last active August 22, 2019 11:49
Mixpanel A/B Testing in Swift
//
// Copyright (c) 2015 Nexar Inc. - All Rights Reserved. Proprietary and confidential.
//
// Unauthorized copying of this file, via any medium is strictly prohibited.
import Foundation
import Mixpanel
public class Tweaks : NSObject, MPTweakObserver {
@JeanMeche
JeanMeche / gist:50102a47937e9896e4f4
Created April 19, 2015 16:47
Levenshtein — swift
/**
* Levenshtein edit distance calculator
* Usage: levenstein <string> <string>
*
* Inspired by https://gist.github.com/bgreenlee/52d93a1d8fa1b8c1f38b
* Improved with http://stackoverflow.com/questions/26990394/slow-swift-arrays-and-strings-performance
*/
class Tools {
@luosheng
luosheng / gist:ea8b0e91c9f0bd1e5245
Created July 24, 2014 02:48
Font with fallback
UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:@{
UIFontDescriptorNameAttribute: @"SourceSansPro-Regular",
UIFontDescriptorCascadeListAttribute:
@[
[UIFontDescriptor fontDescriptorWithFontAttributes:@{ UIFontDescriptorNameAttribute: @"Hiragino Sans GB W3" }]
]
}];
});
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:pointSize];
@visnup
visnup / SlideAnimatedTransitioning.h
Last active November 13, 2023 12:07
iOS 7 screen edge gesture swipe from right to left (similar to edge swiping from left to right) on UINavigationController. *only* the edge swipe uses the custom transition; everything else uses default behaviors.
//
// SlideAnimatedTransitioning.h
// SwipeLeft
//
// Created by Visnu on 4/14/14.
// Copyright (c) 2014 Visnu Pitiyanuvath. All rights reserved.
//
#import <Foundation/Foundation.h>
@berzniz
berzniz / NSObject+Debounce.h
Created January 25, 2014 16:18
Debounce method for Objective C
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@claybridges
claybridges / gist:6029091
Last active October 10, 2023 14:26
UIInterfaceOrientationMask vs. UIInterfaceOrientation. As far as I know, a function like this isn't available in the API. I derived this from the enum def for UIInterfaceOrientationMask.
// UIInterfaceOrientationMask vs. UIInterfaceOrientation
// As far as I know, a function like this isn't available in the API. I derived this from the enum def for
// UIInterfaceOrientationMask.
inline BOOL OrientationMaskSupportsOrientation(UIInterfaceOrientationMask mask, UIInterfaceOrientation orientation) {
return (mask & (1 << orientation)) != 0;
}
@joaofranca
joaofranca / gist:3159618
Created July 22, 2012 13:06
gist 7: iOS - Customize UITableViewCell delete/move overlay views while editing
- (void)layoutSubviews{
[super layoutSubviews];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.0f];
for (UIView *subview in self.subviews) {
@Jach
Jach / mig.py
Created December 30, 2011 04:09
Dirty migration script from Jira issues to Github issues
'''
Steps:
1. Create any milestones
2. Create any labels
3. Create each issue, linking them to milestones and labels
3.1: Update status for new issue if closed
4: Create all the comments for each issue
'''
import getpass
import json
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)