Skip to content

Instantly share code, notes, and snippets.

@akesson
akesson / .gitconfig
Last active April 4, 2017 09:23
Useful git aliases
[alias]
# delete all local tags and then fetch the ones on the server
cleantags = !git tag -l | xargs git tag -d && git fetch -t
# adds and pushes a single tag
addtag = "!f() { git tag $1; git push origin $1; }; f"
# removes all tags matching input on remote only. git removetags string_in_tag
removetags = "!f() { git tag -l | grep $1 | xargs git push --delete origin; echo 'Deleted tags remotely only. If all ok, do a cleantags to remove them locally as well or if NOK use pushtags to re-push them to remote'; }; f"
# push all local tags to server
pushtags = push origin --tags
# find the sha and branch(es) of a tag
@akesson
akesson / test.md
Created December 27, 2016 17:21
Gravizo

![Alt text](http://g.gravizo.com/g? @startuml; actor Lead; actor Dev; actor QA; Lead -> Lead: Create Epic; Lead -> Dev; Dev -> Dev: D1 Acceptance; QA --> Dev: Spec support; Lead --> Dev: Task support;

@akesson
akesson / SwiftTypeErasure.swift
Last active December 11, 2016 17:37
Type Erasure Magic
// from Hector Matos speech Type Erasure Magic
//: https://realm.io/news/altconf-hector-matos-type-erasure-magic/
import UIKit
public struct Transaction {}
protocol CellReloadable: class {
associatedtype DataType
var selectedIndexPath: NSIndexPath? { get set }
@akesson
akesson / Git_commands.md
Last active March 3, 2017 11:50
Useful git commands

Finding which the branch of a tag

Find the sha first:

git log -1 $TAG_NAME --format="%h"

Then check which branch(es) that has the commit:

git branch --contains $SHA
@akesson
akesson / UIImageMetalExtensions.swift
Last active July 29, 2023 19:33
[iOS] Extension for creating UIImage from Metal texture
// http://blog.human-friendly.com/drawing-images-from-pixel-data-in-swift
// https://github.com/FlexMonkey/MetalReactionDiffusion/blob/1ea9aa4a841d20e0b247505fdf716cd5fe1a01fd/MetalReactionDiffusion/ViewController.swift
public struct PixelData {
var a:UInt8 = 255
var r:UInt8
var g:UInt8
var b:UInt8
}
@akesson
akesson / iOSUIImageArray2Video.swift
Last active August 31, 2022 12:45
[iOS] UIImage array 2 Video
//http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie/3742212#3742212
import AVFoundation
import UIKit
import Photos
struct RenderSettings {
var width: CGFloat = 1334
var height: CGFloat = 750
@akesson
akesson / iOSVideoPicking.swift
Last active July 29, 2016 11:23
[iOS] Picking a video
//https://www.raywenderlich.com/94404/play-record-merge-videos-ios-swift
// MARK: - UIImagePickerControllerDelegate
extension PlayVideoViewController: UIImagePickerControllerDelegate {
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
let mediaType = info[UIImagePickerControllerMediaType] as! NSString
dismissViewControllerAnimated(true) {
if mediaType == kUTTypeMovie {
let videoURL = info[UIImagePickerControllerMediaURL] as! NSURL
@akesson
akesson / Percent.swift
Created July 3, 2016 17:57
A little test to make a Percent struct wrapping a Float (could be generic Float/Double)
import Foundation
public struct Percent {
private var _val: Float
}
public func == (left: Percent, right: Percent) -> Bool {
return left._val == right._val
}