Skip to content

Instantly share code, notes, and snippets.

@MrBenJ
MrBenJ / example.js
Last active October 2, 2018 00:41
A real world example of how JS Promises work (A+ Specification)
import { getJSON } from './promise_example';
function init() {
getJSON('my-url.com').then( data => {
// data, the first param of resolve(), contains
// the response data from the XHR request
console.log(data);
}).catch( error => {
// oh no, something went wrong!
// error is the first param of reject()
@schickling
schickling / UIImageFixedOrientationExtension.swift
Last active February 4, 2024 15:00
Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.Up {
return self
}
var transform: CGAffineTransform = CGAffineTransformIdentity