Skip to content

Instantly share code, notes, and snippets.

View pedrol2b's full-sized avatar
🟢
val status = "online"

Pedro Bueno pedrol2b

🟢
val status = "online"
View GitHub Profile
@pedrol2b
pedrol2b / settings.json
Last active June 30, 2024 20:47
VSCode Settings (Updated MacOS)
{
"editor.fontSize": 16,
"editor.lineHeight": 1.8,
"editor.fontFamily": "JetBrains Mono",
"editor.fontWeight": "400",
"editor.fontLigatures": true,
"editor.semanticHighlighting.enabled": false,
"editor.formatOnSave": true,
"editor.largeFileOptimizations": false,
"editor.suggestSelection": "first",
@pedrol2b
pedrol2b / labels.yml
Last active April 11, 2024 12:38
Repository issues labels
- name: ❌-no-repro
description: Reproduction not provided
color: FF0000
- name: ⌨️ accessibility
description: Accessibility concerns
color: FFA500
- name: 🤖 android
description: Android platform
color: 4BC74F
- name: ⚠️ breaking change
@pedrol2b
pedrol2b / App.tsx
Created April 11, 2024 20:37
QR overlay issue
import { StatusBar } from 'expo-status-bar'
import { useEffect, useRef, useState } from 'react'
import { Dimensions, StyleSheet, View } from 'react-native'
import { Polygon, Svg } from 'react-native-svg'
import {
Camera,
Templates,
useCameraDevice,
useCameraFormat,
useCameraPermission,
@pedrol2b
pedrol2b / caesar.c
Created May 5, 2024 21:25
Caesar's cipher algorithm
#include <stdio.h>
/**********************************************************************
*
* caesar.c
* Caesar's cipher algorithm
* Encrypts messages using Caesar's cipher.
* <@pedrol2b>
**********************************************************************/
@pedrol2b
pedrol2b / getAverageLuminance.kt
Created May 31, 2024 14:37
Calculate avarage luminance from an YUV Frame
fun getAverageLuminance(frame: Frame): Double {
require(frame.pixelFormat == PixelFormat.YUV) { "Unsupported pixel format. Expected YUV." }
var totalLuminance = 0.0
val yBuffer = frame.image.planes[0].buffer
while (yBuffer.hasRemaining()) {
@Suppress("MagicNumber")
totalLuminance += yBuffer.get().toInt() and 0xFF
}
@pedrol2b
pedrol2b / invertBitmap.kt
Created May 31, 2024 14:44
Efficiently invert bitmap on Android (Kotlin)
private fun invertBitmap(bitmap: Bitmap): Bitmap {
return Bitmap.createBitmap(bitmap.width, bitmap.height, Bitmap.Config.ARGB_8888).apply {
val canvas = Canvas(this)
val paint = Paint()
val matrixGrayscale = ColorMatrix()
matrixGrayscale.setSaturation(0f)
val matrixInvert = ColorMatrix()
matrixInvert.set(