Skip to content

Instantly share code, notes, and snippets.

View krooked's full-sized avatar

André Niet krooked

View GitHub Profile
@krooked
krooked / init.lua
Created May 17, 2023 11:07
Hammerspoon (https://www.hammerspoon.org) script to add a custom key binding for vim mode in Xcode. Pressing two times the f-key within the time frame exits insert mode in normal vim mode.
local timer = require("hs.timer")
local eventtap = require("hs.eventtap")
local keycodes = require("hs.keycodes")
local events = eventtap.event.types
local timeFrame = 0.2
local f_key = 3
local pressTime, firstDown = 0, false
function twoHandler()
local frontmostAppName = hs.application.frontmostApplication():name()
@krooked
krooked / rungekutta2nd.swift
Last active February 14, 2017 15:12
Runge Kutta 2nd order movement test
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
// Helper functions
func * (point: CGPoint, scalar: CGFloat) -> CGPoint {
return CGPoint(x: point.x * scalar, y: point.y * scalar)
}
func + (left: CGPoint, right: CGPoint) -> CGPoint {
@krooked
krooked / euler.swift
Last active February 14, 2017 15:13
Euler movement test
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
// Helper functions
func * (point: CGPoint, scalar: CGFloat) -> CGPoint {
return CGPoint(x: point.x * scalar, y: point.y * scalar)
}
func + (left: CGPoint, right: CGPoint) -> CGPoint {
@krooked
krooked / drawCircle.swift
Last active February 14, 2017 10:32
Draw circle with UKit in Xcode playground
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
func drawCircle(x: CGFloat, y: CGFloat) {
let p = UIBezierPath(ovalIn: CGRect(x: x, y: y, width: 10, height: 10))
UIColor.blue.setFill()
p.fill()
}
@krooked
krooked / UIImageCropAlphaExtension.swift
Last active November 8, 2022 08:10
Swift: UIImage Crop Alpha
import Foundation
import UIKit
/* Extension for croping transparent pixels
example:
let image: UIImage = UIImage(imageLiteral: "YOUR_IMAGE")
let uiImageView = UIImageView(image: image.cropImageByAlpha())
view.addSubview(uiImageView)
Code was basically done here:
@krooked
krooked / JsonConverter
Last active October 13, 2015 06:37
Convert json object to value object(s)
/**
* Actionscript
* Json to value object converter
*
* @author André Niet
* @version 0.1
*/
package util {
import flash.utils.Dictionary;
import flash.utils.describeType;