This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class SmsMessage(val address: String, val body: String, val date: Long) | |
val context = LocalContext.current | |
var smsList by remember { mutableStateOf<List<SmsMessage>>(emptyList()) } | |
val permissionLauncher = rememberLauncherForActivityResult( | |
ActivityResultContracts.RequestPermission() | |
) { isGranted: Boolean -> | |
if (isGranted) { | |
fetchSms(context) { smsList = it } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.walter.fireapp | |
import android.Manifest | |
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.content.Context | |
import android.content.Intent | |
import android.content.pm.PackageManager | |
import android.location.LocationManager | |
import android.os.Bundle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implementation("com.google.android.gms:play-services-location:21.3.0") | |
@Composable | |
fun getPermissionsLauncher(context: Context): ManagedActivityResultLauncher<Array<String>, Map<String, Boolean>> { | |
val permissionLauncher = | |
rememberLauncherForActivityResult(contract = ActivityResultContracts.RequestMultiplePermissions()) | |
{ | |
val fineLocationGranted = it[Manifest.permission.ACCESS_FINE_LOCATION] ?: false | |
val courseLocationGranted = | |
it[Manifest.permission.ACCESS_COARSE_LOCATION] ?: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add this permission in Manifest file | |
//<uses-permission android:name="android.permission.INTERNET"/> | |
//https://mature-octopus-causal.ngrok-free.app/api/people/new | |
//Code to send data to server | |
fun sendData( | |
context: Context, | |
names: String, | |
//add all other fields here | |
onSuccess: () -> Unit, | |
onError: (String) -> Unit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters': { | |
'verbose': { | |
'format': '{levelname} {asctime} {process:d} {message}', | |
'style': '{', | |
}, | |
}, | |
'handlers': { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from base64 import b64encode | |
from datetime import datetime | |
import requests | |
from requests.auth import HTTPBasicAuth | |
def get_access_token(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unique_filename(path): | |
""" | |
Enforce unique upload file names. | |
Usage: | |
class MyModel(models.Model): | |
file = ImageField(upload_to=unique_filename("path/to/upload/dir")) | |
""" | |
import os, base64, datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reset Jetbrains 2020 Products | |
import glob | |
import os | |
import winreg | |
from os import path | |
from os.path import expanduser | |
home = expanduser("~") | |
newJetbrainsHome = path.join(home, "AppData\Roaming\JetBrains") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Thanks @ketos @krishjun @denis111 | |
## declare array of tools | |
declare -a tools=( | |
"DataGrip" | |
"CLion" | |
"Rider" | |
"PhpStorm" |
NewerOlder