Skip to content

Instantly share code, notes, and snippets.

@snyderra
snyderra / index.html
Last active January 30, 2019 13:45
Margin Calculator
<div class="container">
<span class="label" id="cost-label">Cost($):</span><span class="value" id="cost">0</span>
<span class="label" id="margin-label">Margin(%):</span><span class="value" id="margin">0</span>
<span class="label" id="markup-label">Markup(%):</span><span class="value" id="markup">0</span>
<span class="label" id="revenue-label">Revenue($):</span><span class="value" id="revenue">0</span>
<span class="label" id="profit-label">Profit($):</span><span class="value" id="profit">0</span>
<button class="btn silver clear">C</button>
@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
@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 / 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 / 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
// https://stackoverflow.com/a/60985346
private static String uniqueID = null;
private static final String PREF_UNIQUE_ID = "PREF_UNIQUE_ID";
public synchronized static String id(Context context) {
if (uniqueID == null) {
SharedPreferences sharedPrefs = context.getSharedPreferences(
PREF_UNIQUE_ID, Context.MODE_PRIVATE);
uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
if (uniqueID == null) {
uniqueID = UUID.randomUUID().toString();
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());
def getVersionCode(){
try {
def (major, minor, patch) = getVersionName().split('-')[0].tokenize('.')
(major, minor, patch) = [major, minor, patch].collect{it.toInteger()}
return (major * 1000000) + (minor * 10000) + (patch * 100)
}
catch (ignored) {
return -1;
}
}
from pprint import pprint
import re
import json
def parse_records(records: str):
# see if we have any complete entries
beg = records.index(" # Host name")
end = records.rindex("============================================================================================")
if (beg > 0 and end > 0):
@snyderra
snyderra / smartcurl.sh
Last active October 9, 2024 12:50
Smart Card Curl on Macos
#!/bin/bash
#sudo port install opensc
#sudo port install curl
#sudo port install libp11
export OPENSSL_CONF=$(mktemp)
cat << EOF > $OPENSSL_CONF
openssl_conf = openssl_init
[openssl_init]