Skip to content

Instantly share code, notes, and snippets.

Håvard Fossli hfossli

View GitHub Profile
@hfossli
hfossli / standard.sh
Last active Jul 1, 2020
Standard bash script format
View standard.sh
#!/bin/bash
CLEAR='\033[0m'
RED='\033[0;31m'
function usage() {
if [ -n "$1" ]; then
echo -e "${RED}👉 $1${CLEAR}\n";
fi
echo "Usage: $0 [-n number-of-people] [-s section-id] [-c cache-file]"
@hfossli
hfossli / RxSwift+Optional.swift
Last active Jan 4, 2018
RxSwift + optional
View RxSwift+Optional.swift
// MIT License
//
// Copyright (c) 2016 Thane Gill <me@thanegill.com>
// Copyright (c) 2014-2017 Art.sy, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
@hfossli
hfossli / SHA256-Bridging-Header.h
Last active May 25, 2020
AES 256 in swift 4 with CommonCrypto
View SHA256-Bridging-Header.h
#import <CommonCrypto/CommonCrypto.h>
@hfossli
hfossli / SHA256.swift
Last active Dec 12, 2019
SHA256 in Swift
View SHA256.swift
// This is a heavily altered version of SHA2.swift found in CryptoSwift.
// I tried to remove everything that is not about SHA256.
//
// --========================================================================--
//
// SHA2.swift
// CryptoSwift
//
// Created by Marcin Krzyzanowski on 24/08/14.
View AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
AppVersion.activateAndSaveCurrentVersion()
application.onFirstLaunch {
showWelcomeMessage()
}
application.onUpgrade { (previousVersion, currentVersion) in
migrateData(from: previousVersion, to: currentVersion)
View Display.swift
import UIKit
public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus
@hfossli
hfossli / Fastfile
Last active Oct 24, 2016
Remove duplicate .mobileprovision files locally on your machine
View Fastfile
# If you prefer to have this in yor fastfile
fastlane_version "1.90.0"
default_platform :ios
platform :ios do
lane :duplicates do |options|
remove_local_duplicate_profiles
end
@hfossli
hfossli / RACSignalTest.m
Created Sep 26, 2016
Improving setNameWithFormat: in RAC
View RACSignalTest.m
#import <XCTest/XCTest.h>
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
- (NSString *)name;
@end
@hfossli
hfossli / RACSignalTest.m
Last active Sep 23, 2016
Improving setNameWithFormat: in RAC
View RACSignalTest.m
#import <XCTest/XCTest.h>
#define RACNameBlockFromFormat(...) (^NSString *{\
return [NSString stringWithFormat:__VA_ARGS__]; \
})
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
@hfossli
hfossli / RACSignalTest.m
Created Sep 23, 2016
Improving setNameWithFormat: in RAC
View RACSignalTest.m
#import <XCTest/XCTest.h>
@interface RACSignal : NSObject
- (instancetype)someOperatorWithObject:(NSObject *)object;
- (NSString *)name;
@end
You can’t perform that action at this time.