Skip to content

Instantly share code, notes, and snippets.

Context context = view.getContext();
ContentResolver cr = context.getContentResolver();
ContentValues values;
try {
// create a file for test
File file = new File(context.getFilesDir(), "1234568");
file.createNewFile();
try (OutputStream os = new FileOutputStream(file)) {
os.write("test".getBytes());
@snyderra
snyderra / debounce.kt
Created June 21, 2023 22:46 — forked from mirmilad/debounce.kt
Simple debounce extension for LiveData by using Coroutines
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
fun <T> LiveData<T>.debounce(duration: Long = 1000L, coroutineScope: CoroutineScope) = MediatorLiveData<T>().also { mld ->
val source = this
@snyderra
snyderra / start_cgi_http_server.sh
Created January 22, 2021 01:32 — forked from ohtomi/start_cgi_http_server.sh
File Upload CGI Script written in Python
#!/bin/bash
mkdir ./cgi-bin/
cp upload.cgi ./cgi-bin/
chmod +x ./cgi-bin/upload.cgi
mkdir ./upload/
python -m CGIHTTPServer 8080
@snyderra
snyderra / Microsoft-Teams-GPU-Fixer.sh
Created January 22, 2020 01:09 — forked from Cosmo/Microsoft-Teams-GPU-Fixer.sh
Disable GPU usage for Microsoft Teams
APP=TeamsFixer
mkdir -vp ${APP}.app/Contents/MacOS ${APP}.app/Contents/Resources
PATH="$PATH:/usr/libexec"
printf '#!/usr/bin/env bash\nexec /Applications/Microsoft\ Teams.app/Contents/MacOS/Teams --disable-gpu' > ${APP}.app/Contents/MacOS/${APP}
chmod +x ${APP}.app/Contents/MacOS/${APP}
cp /Applications/Microsoft\ Teams.app/Contents/Resources/icon.icns ${APP}.app/Contents/Resources/icon.icns
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleDisplayName string ${APP}"
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleIconFile string icon.icns"
PlistBuddy ${APP}.app/Contents/version.plist -c "add ProjectName string ${APP}"
find ${APP}.app
@snyderra
snyderra / export_messages.py
Last active September 21, 2019 14:39 — forked from hastyeagle/export_messages.py
Export iOS/iMessage chat logs to HTML or text
#!/usr/bin/env python
import sys
import argparse
import urllib
# import urlparse
import base64
import mimetypes
import html
import sqlite3