Skip to content

Instantly share code, notes, and snippets.

View AdamLantz's full-sized avatar
🎉
Having a blast!

Adam Lantz AdamLantz

🎉
Having a blast!
View GitHub Profile
@AdamLantz
AdamLantz / UIImage+Cropping.swift
Created June 20, 2018 16:03
Swift 4 - Crop transparent pixels from UIImage
//Swift 4 modifications for this gist: https://gist.github.com/krooked/9c4c81557fc85bc61e51c0b4f3301e6e
import Foundation
import UIKit
extension UIImage {
func cropImageByAlpha() -> UIImage {
let cgImage = self.cgImage
let context = createARGBBitmapContextFromImage(inImage: cgImage!)
let height = cgImage!.height
let width = cgImage!.width
@AdamLantz
AdamLantz / konami.js
Created March 30, 2017 22:54
Javascript file to listen for Konami code to be entered by keyboard
/**
* Created by adamg on 3/29/2017.
*/
(function(){
var charSet = ["ArrowUp","ArrowUp","ArrowDown","ArrowDown","ArrowLeft","ArrowRight","ArrowLeft","ArrowRight","b","a"];
var charInSet = 0;
document.addEventListener('keydown',function(e){
if(e.key == charSet[charInSet]){
console.log("Match for char: " + charSet[charInSet]);
charInSet++;