Skip to content

Instantly share code, notes, and snippets.

View codytwinton's full-sized avatar
:octocat:
Why is status a thing?

Cody Winton codytwinton

:octocat:
Why is status a thing?
View GitHub Profile
@tonnylitao
tonnylitao / 0KeyboardShowAndHideProtocol.swift
Last active June 19, 2018 08:23
KeyboardShowAndHide Protocol
import UIKit
// KeyboardAvoidable
// original by Roy McKenzie
protocol KeyboardShowAndHideProtocol: class {
typealias KeyboardHeightDuration = (height: CGFloat, duration: Double)
typealias KeyboardHeightDurationBlock = (KeyboardHeightDuration) -> Void
@roymckenzie
roymckenzie / KeyboardAvoidable.swift
Last active September 6, 2022 19:42
Easy way to get your view controllers to respect appearance of the keyboard.
// KeyboardAvoidable
// Roy McKenzie
protocol KeyboardAvoidable: class {
func addKeyboardObservers(customBlock: ((CGFloat) -> Void)?)
func removeKeyboardObservers()
var layoutConstraintsToAdjust: [NSLayoutConstraint] { get }
}
var KeyboardShowObserverObjectKey: UInt8 = 1
@sakrist
sakrist / gist:f97499de2dd6687d6403
Last active April 22, 2020 06:40
Objective-C Language Enhancements

Objective-C APIs can now express the “nullability” of parameters, return types, properties, variables, etc. For example, here is the expression of nullability for several UITableView APIs:

-(void)registerNib:(nonnull UINib *)nib forCellReuseIdentifier:(nonnull NSString *)identifier;
-(nullable UITableViewCell *)cellForRowAtIndexPath:(nonnull NSIndexPath)indexPath;
@property (nonatomic, readwrite, retain, nullable) UIView *backgroundView;

The nullability qualifiers affect the optionality of the Objective-C APIs when in Swift. Instead of being imported as implicitly-unwrapped optionals (e.g., UINib!), nonnull-qualified types are imported as non-optional (e.g., UINib) and nullable-qualified types are imported as optional (e.g., UITableViewCell?), so the above APIs will be seen in Swift as:

func registerNib(nib: UINib, forCellReuseIdentifier identifier: String)
@mandiwise
mandiwise / Count lines in Git repo
Last active July 4, 2024 16:56
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
struct Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: self.options, error: nil)
}
init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@StefanLage
StefanLage / Array-Equilibrium
Last active March 31, 2022 19:59
Technical Interview : Equilibrium index of an Array
int equilibrium (int A[], int n){
int sum = 0;
int solution = -1;
int leftSum = 0;
int rightSum = 0;
// Calculate the sum of all P in A
for (int i = 0; i < n; i++)
sum += A[i];
// Try to find an equilibrium -> if yes return the first one
for (int i = 0; i < n; i++){
@amaxwell01
amaxwell01 / interviewitems.MD
Created September 15, 2012 14:17
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go