Skip to content

Instantly share code, notes, and snippets.

View marcusmotill's full-sized avatar
👋

Marcus Motill marcusmotill

👋
View GitHub Profile
@marcusmotill
marcusmotill / BitmapUtils.kt
Created March 12, 2016 18:36
Image compression for Android in Kotlin
class BitmapUtils {
companion object
}
fun BitmapUtils.Companion.getCompressedImage(pathName: String, scalingLogic: ImageView.ScaleType): String {
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeFile(pathName, options)
options.inJustDecodeBounds = false
val dstWidth: Double = ((options.outWidth.toDouble() / (options.outWidth.toDouble() * options.outHeight.toDouble())) * 1000) * options.outWidth.toDouble()
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions