Skip to content

Instantly share code, notes, and snippets.

@akaita
akaita / js_script.cfm
Created November 19, 2019 14:12
Custom tag for ColdFusion implementing cache busting
<!---
Goal: implement timestamp-based cache busting
For example: instead of loading a javascript file from "http://www.example.com/myscript.js", it'll load it from "http://www.example.com/myscript.js?20191101160030"
Usage examples:
- add as global tag and: <CF_js_script src="/js/myscript.js">
- <cfimport prefix="akaita" taglib="customTags"> and then <akaita:js_script src="/js/myscript.js"></akaita:js_script>
--->
<CFSETTING ENABLECFOUTPUTONLY="Yes">
@akaita
akaita / encryptedsharedpreferences-12.kt
Last active January 28, 2020 07:45
encryptedsharedpreferences-12.kt
// Step 1: Create or retrieve the Master Key for encryption/decryption
val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
// Step 2: Initialize/open an instance of EncryptedSharedPreferences
val sharedPreferences = EncryptedSharedPreferences.create(
"PreferencesFilename",
masterKeyAlias,
applicationContext,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
@akaita
akaita / page_withjs.cfm
Created November 19, 2019 14:16
Usage example of https://gist.github.com/akaita/63cd58a1c91b81313cb50316a22e899c custom tag for Coldfusion cache busting
<cfimport prefix="divvy" taglib="/customTags">
...
...
<!--- <script src="/js/myscript.js"></script> --->
<akaita:js_script src="/js/myscript.js"></akaita:js_script>
...
@akaita
akaita / encryptedsharedpreferences-4.kt
Last active October 13, 2019 00:34
encryptedsharedpreferences-4.kt
// Step 3: Read data from EncryptedSharedPreferences as usual
val value = sharedPreferences.getString("DATA", "")
@akaita
akaita / encryptedsharedpreferences-cleartext.xml
Created October 13, 2019 00:26
encryptedsharedpreferences-cleartext.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="DATA">akaita</string>
</map>
@akaita
akaita / encryptedsharedpreferences-encrypted.xml
Created October 13, 2019 00:25
encryptedsharedpreferences-encrypted.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="AVz2qCVxm1KudCCJKYuxuoaAXoPeWKjG0w==">ASnO9uni11t3m9sNgDJbiYllL/tE+i99TYKfQ0h8XV6AUN0O3rBxBsMmcpw2DCY=</string>
<string name="__androidx_security_crypto_encrypted_prefs_key_keyset__">12a901eb372af4775b09f5b51d20d49428931c5d8e0b17dd103d2169c1879b8b13958274d7e25d3cc052f301461495fd40b70806ae244f456726802460318bdf19dce444e7a60f20c903c5a57140ea8e90a19a1b48559961d145a50000d1c0e22ca918b02ea0cc34e433900f44c00e9c791ecb678f26d293c0226d6c2a9e25e610616ec34241b06410481427a850eeedf85ee4c725d5dbd715b5a8d0e017be9a568a9f960989271d14d2d0531a4408a5d0dae705123c0a30747970652e676f6f676c65617069732e636f6d2f676f6f676c652e63727970746f2e74696e6b2e4165735369764b6579100118a5d0dae7052001</string>
<string name="__androidx_security_crypto_encrypted_prefs_value_keyset__">12880189e734bbbf9cfa3bc15b5e53ea8df03341269cf97112a60a1f6482732dd33248b3f821397fb04ef3372ff54336e9045a0b0c0fb7afdf475dbc98a1107d09de66afcc5ad063e5e5b59a7d616e14834e19769bc84de7e5c8716a8
@akaita
akaita / encryptedsharedpreferences-3.kt
Created October 12, 2019 23:12
encryptedsharedpreferences-3.kt
// Step 3: Save data to the EncryptedSharedPreferences as usual
sharedPreferences.edit()
.putString("DATA", saveText.text.toString())
.apply()
@akaita
akaita / encryptedsharedpreferences-build2.gradle
Created October 12, 2019 23:09
encryptedsharedpreferences-build2.gradle
implementation "androidx.security:security-crypto:1.0.0-alpha02"
@akaita
akaita / encryptedsharedpreferences-build.gradle
Last active October 12, 2019 23:08
encryptedsharedpreferences-build.gradle
minSdkVersion 23
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 4
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
...