Skip to content

Instantly share code, notes, and snippets.

View nathanmkaya's full-sized avatar
🎯
Focusing

Nathan Mkaya nathanmkaya

🎯
Focusing
View GitHub Profile
@msramalho
msramalho / Cryptography.java
Created January 13, 2020 22:59
Java Class to manage cryptography keys in Android Keystore using "AES/CBC/PKCS7Padding" - encrypt and decrypt strings
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.util.Base64;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@benediktg
benediktg / pam_kwallet-guide.md
Last active May 14, 2023 14:48
Short guide for pam_kwallet with KDE Plasma 5 on openSUSE

(based on these two blog entries and inspired by Fedora-Blog)

First install pam_kwallet:

sudo zypper in pam_kwallet

Then edit the files /etc/pam.d/passwd, /etc/pam.d/login and /etc/pam.d/sddm as follows, i.e. add the lines beginning with a - (the hyphens are valid PAM syntax to reduce log entries if these PAM modules should not exist) and ending with the ### comment:

/etc/pam.d/passwd :

@wolever
wolever / histogram.sql
Last active April 19, 2023 20:28
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------
@jaredsburrows
jaredsburrows / RxBus1.java
Last active March 16, 2023 10:44
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@redleafar
redleafar / add_footer_navigation_drawer.md
Created February 25, 2017 01:17
Add footer to NavigationDrawer
@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