Skip to content

Instantly share code, notes, and snippets.

Håvard Fossli hfossli

Block or report user

Report or block hfossli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View port.py
import binascii, base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat, load_pem_public_key, PrivateFormat, load_pem_private_key, NoEncryption
from cryptography.hazmat.primitives.kdf.x963kdf import X963KDF
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
@hfossli
hfossli / switch.swift
Last active Jan 28, 2019
Switch constants easily with this swift CLI
View switch.swift
#!/usr/bin/swift
import Foundation
struct Config {
enum Environment: String {
case dev
case prod
}
var environment: Environment = .prod
@hfossli
hfossli / ASN1.swift
Created Nov 9, 2018
ASN1 DER encoder and decoder in swift
View ASN1.swift
//
// ASN1.swift
// ASN1
//
// Created by Håvard Fossli on 29.08.2018.
// Copyright © 2018 Håvard Fossli. All rights reserved.
//
import Foundation
@hfossli
hfossli / WKWebViewKeyLogger.m
Created Oct 11, 2018
WKWebViewKeyLogger will automatically add itself to the objc runtime and add a keylogger to any WKWebView created
View WKWebViewKeyLogger.m
//
// Author: Håvard Fossli <hfossli@agens.no>
//
// Copyright (c) 2018 Agens AS (http://agens.no/)
//
// 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
@hfossli
hfossli / swiff.swift
Last active Jan 15, 2019
Blazing fast and human readable time diffs lines of output when running build commands like fastlane
View swiff.swift
#!/usr/bin/env xcrun swift
import Darwin
import Foundation
struct ANSIColors {
static let clear = "\u{001B}[0m"
static let red = "\u{001B}[38;5;160m"
static let orange = "\u{001B}[38;5;202m"
static let yellow = "\u{001B}[38;5;220m"
@hfossli
hfossli / time-diff-output.sh
Created Aug 1, 2018
Get time difference between output line. Supports logs from fastlane as well!
View time-diff-output.sh
#!/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 Jun 29, 2018
Get time difference between output lines from fastlane
View fastlane-diff.sh
#!/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 Apr 23, 2018
Script for building dynamic framework
View build.sh
#!/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 Oct 17, 2018
Get notified when new booking hours is available at Politihuset Grønland or Politihuset Sandvika
View date-compare.sh
#!/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 Sep 23, 2019
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]"
You can’t perform that action at this time.