Skip to content

Instantly share code, notes, and snippets.

View mbernson's full-sized avatar
👨‍💻
Coding...

Mathijs Bernson mbernson

👨‍💻
Coding...
View GitHub Profile
@mbernson
mbernson / easter.swift
Created March 26, 2019 16:33
All Easter dates from the year 0 until 2100
import Foundation
func easter(for year: Int) -> Date? {
// Code from Gist: https://gist.github.com/duedal/2eabcede718c69670102
let a = year % 19
let b = Int(floor(Double(year) / 100))
let c = year % 100
let d = Int(floor(Double(b) / 4))
let e = b % 4
let f = Int(floor(Double(b+8) / 25))
@mbernson
mbernson / UIImage+Tinted.swift
Created January 10, 2019 09:08
Applies a tint color to a uiimage
import UIKit
extension UIImage {
func tinted(withColor color: UIColor) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
defer { UIGraphicsEndImageContext() }
let rect = CGRect(origin: .zero, size: size)
// Tint the image
self.draw(in: rect)
@mbernson
mbernson / phone.py
Created December 9, 2018 15:59
AIY Phone project
#!/usr/bin/env python3
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@mbernson
mbernson / notification_callback_add.php
Last active January 2, 2018 19:10
Listing/adding/removing notification filters using the bunq API
<?php
use bunq\Context\ApiContext;
use bunq\Model\Generated\Endpoint\User;
use bunq\Model\Generated\Endpoint\UserCompany;
use bunq\Model\Generated\Endpoint\UserPerson;
use bunq\Model\Generated\Object\NotificationFilter;
require 'vendor/autoload.php';
@mbernson
mbernson / diff.txt
Created April 10, 2017 08:41
Eachine AIOF3_BRUSHED Flight Controller Flysky default config
# diff
# version
# BetaFlight/OMNIBUS 3.0.1 Oct 18 2016 / 10:21:07 (48b7b4f)
# name
# mixer
# servo
@mbernson
mbernson / gist:3d501bcaa453b477752de8d414fb9ec6
Last active March 22, 2017 09:20
Bertcopter Betafligth settings (diff output)
CLI
# diff
# Betaflight / OMNIBUS 3.1.6 Mar 6 2017 / 22:16:32 (1fd502c3)
name Bertcopter
feature -RX_PPM
feature -CURRENT_METER
feature -OSD
feature RX_SERIAL
@mbernson
mbernson / StateViewController.swift
Last active March 3, 2017 08:54
State ViewController
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
enum State<T, U> {
case empty
case loading
case content(T)
case error(U)
@mbernson
mbernson / gist:83bb9eef53e2b5f22bfa16be62ea49f9
Created February 12, 2017 12:43
martian 2 omnibus f3 settings
# dump
# Betaflight / OMNIBUS 3.1.5 Feb 7 2017 / 22:19:42 (4646f9d)
name bertcopter
resource BEEPER 1 C15
resource MOTOR 1 B08
resource MOTOR 2 B09
resource MOTOR 3 A03
resource MOTOR 4 A02
resource MOTOR 5 B07
resource MOTOR 6 B06
@mbernson
mbernson / gitsha.sh
Created January 19, 2017 09:58
iOS app Git SHA
#!/bin/sh
# Write git sha to info plist
set -o errexit
set -o nounset
GITSWIFTFILE="$SRCROOT/MyApp/Resources/Git.generated.swift"
GIT_SHA=$(git rev-parse --verify HEAD | cut -c 1-7)
@mbernson
mbernson / gist:b0d781cecd7682a9825911fa3a813291
Created December 10, 2016 09:20
f3_evo_brush factory cleanflight config
# dump
# version
# Cleanflight/SPRACINGF3EVO 1.13.0 Jun 6 2016 / 00:03:29 (a77bc76)
# dump master
# mixer
mixer QUADX
mmix reset
smix reset