Skip to content

Instantly share code, notes, and snippets.

View thexande's full-sized avatar

Alexander Murphy thexande

  • Denver, CO, USA, Planet Earth
View GitHub Profile
@vinnybad
vinnybad / Fastfile
Created June 3, 2016 19:16
Shows one way to fail a build in fastlane when code coverage does not meet a minimum threshold.
#
# Shows one way to fail a build in fastlane when code
# coverage does not meet a minimum threshold.
#
# there are other ways to check the coverage of the commit,
# but I couldn't find an existing tool that makes this easier
# that will run on bitrise. I would have normally used diff-cover
# to do this because you can compare branches and only check the diffs.
# Unfortunately that means you have to find a way to install it on bitrise
# at the time of writing and that can be tricky.
func generate(numRows: Int) -> [[Int]] {
var results = [[Int]]()
if (numRows == 0) {
return results
}
for i in 0..<numRows {
var currentResults = [Int]()
for j in 0...i {
if (i > 1 && j > 0 && j < i) {
let value = results[i-1][j] + results[i-1][j-1]
@gregpardo
gregpardo / RxSwift+Realm.swift
Last active December 25, 2016 23:15
Simple extension on results object for swift realm
extension Realm {
public func rx_objectForPrimaryKey<T: Object>(type: T.Type, key: AnyObject) -> Observable<T?> {
return self.objects(type)
.filter("%K = %@", self.schema[type.className()]!.primaryKeyProperty!.name, key)
.rx_result
}
}
extension Results where T: Object {
//
// UIBarButtonItem+Badge.swift
// PiGuardMobile
//
// Created by Stefano Vettor on 12/04/16.
// Copyright © 2016 Stefano Vettor. All rights reserved.
//
import UIKit
@YusukeHosonuma
YusukeHosonuma / ValidationViewController.swift
Created April 11, 2016 16:32
RxSwift - Validation sample
import UIKit
import RxSwift
import RxCocoa
let requiredUserNameLength = 5
let requiredPasswordLength = 5
let limitUserNameLength = 20
class ValidationViewController: UIViewController {
@naoty
naoty / Playground.swift
Last active April 6, 2018 23:42
A playground to display a table view controller on a navigation controller
import XCPlayground
import UIKit
struct Pokemon {
let id: UInt
let name: String
}
class PokedexViewController: UITableViewController {
let pokemons: [Pokemon] = [
@SpacyRicochet
SpacyRicochet / Money.swift
Last active February 9, 2019 12:13
Extension of protocol cannot have inheritance clause
protocol Money {
var value: Double { get }
var inGold: Double { get }
var symbol: String { get }
}
// Sadly, gives a compiler error.
// "Extension of protocol 'Money' cannot have an inheritance clause"
extension Money: CustomStringConvertible {
var description: String {
@lopspower
lopspower / README.md
Last active April 29, 2025 07:43
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@camdenfullmer
camdenfullmer / CMFWallpaper.m
Last active February 18, 2024 03:05
Set the wallpaper (lock and/or home screen) on iOS using Apple's private API. Please be aware that including this code in an App Store submission will result in a rejection. This has only been tested on iOS 9.2.
@implementation CMFWallpaper
+ (void)setImage:(UIImage *)image {
NSAssert([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized, @"access to photos is needed to set the wallpaper");
NSString *path;
#if TARGET_OS_SIMULATOR
path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibrary.framework";
#else
path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework";
@angstwad
angstwad / git-lg.sh
Created January 12, 2016 17:31
Better Git Log (git lg)
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"