Skip to content

Instantly share code, notes, and snippets.

View oianmol's full-sized avatar
🏠
Working from home

Anmol Verma oianmol

🏠
Working from home
View GitHub Profile
@oianmol
oianmol / PlaygroundImageToIos.kt
Created March 30, 2024 11:02
Image bytes to file kmp
@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
private fun ByteArray.toNSData(): NSData = NSMutableData().apply {
if (isEmpty()) return@apply
[email protected] {
appendBytes(it.addressOf(0), size.convert())
}
}
@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
private fun NSData.toByteArray(): ByteArray {
#!/usr/bin/env node
const axios = require('axios');
const yargs = require('yargs/yargs');
const {hideBin} = require('yargs/helpers');
class AxisControls {
constructor(cameraIP, username, password) {
// Replace these with your actual camera details
this.baseUrl = `http://${username}:${password}@${cameraIP}/axis-cgi/com/ptz.cgi`;
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
@oianmol
oianmol / motion_detection.py
Created November 11, 2023 07:53
motion_detection.py
# Python program to implement
# Webcam Motion Detector
import os
# importing OpenCV, time and Pandas library
import cv2, time, pandas
import numpy as np
import ffmpegcv
# importing datetime class from datetime library
@oianmol
oianmol / SplitView.kt
Created August 19, 2023 10:31
Jetpack Compose Split view
@Preview(showSystemUi = true, showBackground = true)
@Composable
fun PrevSplitView() {
MaterialTheme {
Box(Modifier.fillMaxSize()) {
SplitView(topView = {
Box(
it
.background(Color.Yellow)
)
@oianmol
oianmol / ios.yml
Created June 20, 2023 17:42
Build and release ios github actions example
name: Build & Deploy
on:
push:
branches:
- master
jobs:
build-ios:
@oianmol
oianmol / platform.android.kt
Created May 19, 2023 10:01
Jetpack Compose Side Effect to update Android or iOS status-bar and navigation-bar color
@Composable
actual fun PlatformColors(statusBarColor: Color, navBarColor: Color){
val sysUiController = rememberSystemUiController()
SideEffect {
sysUiController.setSystemBarsColor(color = topColor)
sysUiController.setNavigationBarColor(color = bottomColor)
}
}
@oianmol
oianmol / QrScannerScreen.android.kt
Last active September 26, 2024 04:14
QR Code Scanner with Jetbrains Jetpack compose multiplatform!
import android.Manifest
import android.content.pm.PackageManager
import android.util.Log
import android.view.ViewGroup
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="abc_decor_view_status_guard">#ff000000</color>
<color name="abc_decor_view_status_guard_light">#ffffffff</color>
<color name="abc_search_url_text_normal">#7fa87f</color>
<color name="abc_search_url_text_pressed">@android:color/black</color>
<color name="abc_search_url_text_selected">@android:color/black</color>
<color name="accent_material_dark">@color/material_deep_teal_200</color>
<color name="accent_material_light">@color/material_deep_teal_500</color>
<color name="alert_default_error_background">#f44336</color>
import Some.MutableLiveData
class MyActivity {
private val button = Button()
val vm = MyViewModel()
fun onCreate(){
vm.liveData.observe{value->
///