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 ssl | |
import socket | |
import urllib.parse | |
from OpenSSL import SSL, crypto | |
def get_certificate_chain(hostname, port=443): | |
context = SSL.Context(SSL.SSLv23_METHOD) | |
context.set_verify(SSL.VERIFY_NONE, lambda *args: True) | |
conn = SSL.Connection(context, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) |
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 os | |
# os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' | |
from flask import Flask, request, jsonify | |
from requests_oauthlib import OAuth2Session | |
import uuid | |
import time | |
from cryptography import x509 | |
from cryptography.x509.oid import NameOID | |
from cryptography.hazmat.primitives import hashes, serialization | |
from cryptography.hazmat.primitives.asymmetric import rsa |
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 | |
#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] |
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
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): |
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 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; | |
} | |
} |
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
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()); |
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
// 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(); |
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 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 |
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 | |
mkdir ./cgi-bin/ | |
cp upload.cgi ./cgi-bin/ | |
chmod +x ./cgi-bin/upload.cgi | |
mkdir ./upload/ | |
python -m CGIHTTPServer 8080 |
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
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 |
NewerOlder