Skip to content

Instantly share code, notes, and snippets.

@hfossli
hfossli / time-diff-output.sh
Created August 1, 2018 08:44
Get time difference between output line. Supports logs from fastlane as well!
#!/bin/bash
CLEAR='\033[0m'
RED='\033[38;5;160m'
ORANGE='\033[38;5;202m'
YELLOW='\033[38;5;220m'
GREEN='\033[0;32m'
BLUE='\033[0;36m'
GREY='\033[38;5;237m'
@hfossli
hfossli / fastlane-diff.sh
Last active June 29, 2018 14:28
Get time difference between output lines from fastlane
#!/bin/bash
CLEAR='\033[0m'
RED='\033[38;5;160m'
ORANGE='\033[38;5;202m'
YELLOW='\033[38;5;220m'
GREEN='\033[0;32m'
BLUE='\033[0;36m'
GREY='\033[38;5;237m'
@hfossli
hfossli / build.sh
Created April 23, 2018 21:11
Script for building dynamic framework
#!/bin/bash
BASEDIR="$( cd "$(dirname "$0/")" ; pwd -P )"
BUILD_DIR="$BASEDIR/Builds"
PROJECT_FILE="Butterfly.xcodeproj"
PRODUCT_NAME="Butterfly"
TARGET_NAME="Butterfly-iOS"
CONFIGURATION="Release"
CLEAR='\033[0m'
@hfossli
hfossli / date-compare.sh
Last active October 17, 2018 11:35
Get notified when new booking hours is available at Politihuset Grønland or Politihuset Sandvika
#!/bin/bash
first_is_earlier() {
y1=$(date -jf '%d.%m.%y%y' "$1" +'%Y' 2> /dev/null)
y2=$(date -jf '%d.%m.%y%y' "$2" +'%Y' 2> /dev/null)
m1=$(date -jf '%d.%m.%y%y' "$1" +'%m' 2> /dev/null)
m2=$(date -jf '%d.%m.%y%y' "$2" +'%m' 2> /dev/null)
d1=$(date -jf '%d.%m.%y%y' "$1" +'%d' 2> /dev/null)
d2=$(date -jf '%d.%m.%y%y' "$2" +'%d' 2> /dev/null)
if [ $y2 -gt $y1 ] ; then
@hfossli
hfossli / standard.sh
Last active February 8, 2024 05:19
Standard bash script format
#!/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 January 4, 2018 15:21
RxSwift + optional
// 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 April 9, 2024 01:05
AES 256 in swift 4 with CommonCrypto
#import <CommonCrypto/CommonCrypto.h>
@hfossli
hfossli / SHA256.swift
Last active June 28, 2022 09:52
SHA256 in 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.
@hfossli
hfossli / AppDelegate.swift
Last active February 29, 2020 02:01
AppVersion
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)
@hfossli
hfossli / Display.swift
Last active July 13, 2020 16:22
Display mode
import UIKit
public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus