Skip to content

Instantly share code, notes, and snippets.

@vanelizarov
vanelizarov / exif.js
Last active May 17, 2019 09:24
javascript - get image EXIF orientation in degrees
// The original solution uses DataView
// Here I'm using custom getUint86 and getUint16 functions to understand
// how things work under the hood
function getUint16(bytes, offset, littleEndian = false) {
const value = bytes[offset] << 8 | bytes[offset + 1]
if (littleEndian) {
return reverseBytes(value)
}
@vanelizarov
vanelizarov / exif.kt
Created May 17, 2019 09:18
kotlin - get image EXIF orientation in degrees
fun getUint16(bytes: List<Int>, offset: Int, littleEndian: Boolean): Int {
val value = (bytes[offset] shl 8) or bytes[offset + 1]
return if (littleEndian) value.reverseBytes() else value
}
fun getUint32(bytes: List<Int>, offset: Int, littleEndian: Boolean): Int {
val value = (bytes[offset] shl 24) or (bytes[offset + 1] shl 16) or (bytes[offset + 2] shl 8) or bytes[offset + 3]
return if (littleEndian) value.reverseBytes() else value
}
@vanelizarov
vanelizarov / xcode-build-bump.sh
Created November 3, 2015 19:22 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)