Skip to content

Instantly share code, notes, and snippets.

View wajahatkarim3's full-sized avatar
:octocat:
Subscribe to my newsletter: remotekaro.substack.com

Wajahat Karim wajahatkarim3

:octocat:
Subscribe to my newsletter: remotekaro.substack.com
View GitHub Profile
@wajahatkarim3
wajahatkarim3 / linkpreview.html
Created February 7, 2024 17:23
LinkPreview Shortcode for Hugo websites
<!-- reset scratch variables at the start -->
{{ $.Scratch.Set "bl_title" false }}
{{ $.Scratch.Set "bl_subtitle" false }}
{{ $.Scratch.Set "bl_link" false }}
{{ $.Scratch.Set "bl_thumbnail" false }}
{{ if .IsNamedParams }}
{{ $.Scratch.Set "bl_subtitle" (.Get "subtitle") }}
{{ $.Scratch.Set "bl_link" (.Get "link") }}
{{ $.Scratch.Set "bl_thumbnail" (.Get "thumbnail") }}
object YourKeys {
init {
System.loadLibrary("native-lib")
}
external fun apiKey(): String
}
#include <jni.h>
#include <string>
extern "C" JNIEXPORT jstringJNICALL
Java_com_package_name_YourKeys_apiKey(JNIEnv *env, jobject object) {
std::string api_key = "your_api_key";
return env->NewStringUTF(api_key.c_str());
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.texturelabs.rosera.pop_movies"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
object Constants {
const val API_KEY = "abcdefg2q4qsaf34rtyy421k"
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--API Key-->
<string name="api_key">abcdefg2q4qsaf34rtyy421k</string>
</resources>
val securePreferences = EncryptedSharedPreferences.create(
"secure_prefs",
mainKeyAlias,
applicationContext,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
// Storing Data in Preferences
with(securePreferences.edit()) {
val keyGenParameterSpec = MasterKeys.AES256_GCM_SPEC
val mainKeyAlias = MasterKeys.getOrCreate(keyGenParameterSpec)
val preferences = getSharedPreferences("normal_prefs", MODE_PRIVATE)
// Storing Data in Preferences
with(preferences.edit()) {
putBoolean("Bool", true)
putString("String", "Some normal string value")
putInt("Integer", 10)
commit()
}
object CustomerData {
var customerId = “123”
var name = “John”
var totalBill = 284.34
var purchasedItems: List<Item> = arrayListOf()
fun addItem(item: Item) {
purchasedItems.add(item)
totalBill = calculateBill()
}