Skip to content

Instantly share code, notes, and snippets.

View adrie4mac's full-sized avatar

Adriyadi Savana adrie4mac

View GitHub Profile
@adrie4mac
adrie4mac / multiple_ssh_setting.md
Created January 13, 2023 09:59 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@adrie4mac
adrie4mac / ECDHKeyExchange.java
Created December 16, 2022 04:30
Key exchange ECDH
package id.adriyadisavana;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.modes.GCMBlockCipher;
import org.bouncycastle.crypto.params.AEADParameters;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.interfaces.ECPrivateKey;
import org.bouncycastle.jce.interfaces.ECPublicKey;
import android.hardware.camera2.CaptureRequest
import android.util.Range
import androidx.camera.camera2.interop.Camera2Interop
private val imageAnalysisCaptureRequestOption by lazy {
val builder = ImageAnalysis.Builder()
Camera2Interop.Extender(builder).apply {
setCaptureRequestOption(
CaptureRequest.CONTROL_AE_MODE,
CaptureRequest.CONTROL_AE_MODE_OFF,
import com.google.mlkit.vision.barcode.Barcode
import com.google.mlkit.vision.barcode.BarcodeScannerOptions
import com.google.mlkit.vision.barcode.BarcodeScanning
import com.google.mlkit.vision.common.InputImage
private fun qrCodeAnalyzer(imageAnalysis: ImageAnalysis) {
imageAnalysis.setAnalyzer(cameraExecutor, QrCodeAnalyzer { qrCodeResult ->
if (processingBarcode.compareAndSet(false, true)) {
Log.d("qr code", qrCodeResult.orEmpty())
}
package main
import (
"crypto/rand"
"fmt"
"math/big"
)
func main() {
prime, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFF966afce3459018f52cfef39ddc76bd182ecb1d6c995c3fd6358cac83931ae7d03e0b47ff48fe45570c2fcbe11beac6c5e9795886b066930240295786034f7c4e7944467f7c3a0f3e98ae7adb6f89fe03c93fcb901d01ce67cb797bc337d4ba01fca91045b09234644b987e18a7a2a2ebba60ab7323a38264d6f67ba900b4ab0315d6c7e50c1d0e6da6da5945f1e6d7078f9dbf2a240a90cecc0861c0c8691bb133fee74a8c90d2ca2366ad72cf252b7fda7de0b8d869072cf3d3ad34d46d04f4fcc84b2fb9e1219678b8afc96e7678218ff50c20529edfa416e51a580d140e2bb4807b4112daad6d093e26736126376257532d6239c7a464a8bd754fe7170572bb4fa8a682975e8dabccc7bb5c5e5223a39c09d3c88bb2b5c0622bb60f4d3ea9000a8f42339cb4ac2cfbb8ae8b33aeeebe07c0f1ccc3e6fa072cf280b5423194da1b55b2f1d9240234ea5f4d1dfe879ecf5f5f53b7f8916db03be16132afcd73661813160e865e8c3f6fcd1f35e048aeFFFFFFFFFFFFFFFF", 16)
@adrie4mac
adrie4mac / git_data.txt
Last active November 29, 2019 07:45
Moving Git repository content to another repository preserving history
# Fetch changes from all remotes and locally delete
# remote deleted branches/tags etc
# --prune will do the job :-;
git fetch --all --prune
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
@adrie4mac
adrie4mac / LiveDataExt.kt
Created March 11, 2019 19:19 — forked from y-polek/LiveDataExt.kt
'map' and 'combineLatest' transformations for LiveData
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MediatorLiveData
import android.arch.lifecycle.MutableLiveData
fun <X, Y> LiveData<X>.map(func: (X?) -> Y?): MutableLiveData<Y?> {
return MediatorLiveData<Y>().apply {
addSource(this@map) { x -> value = func(x) }
}
}
@adrie4mac
adrie4mac / AndroidManifest.xml
Created July 29, 2018 19:42 — forked from erkattak/AndroidManifest.xml
Android Application Setup for use with Charles Proxy
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
/**
* Checks if the device is rooted.
*
* @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
*/
public static boolean isRooted() {
// get from build info
String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys")) {
@adrie4mac
adrie4mac / android_studio_shortcuts.md
Created March 14, 2018 06:46 — forked from stkent/android_studio_shortcuts.md
Android Studio Shortcuts (Mac)

Android Studio Shortcuts (Mac)

Notes:

  • Two of the most useful shortcuts utilize the Fn (function) keys. It is therefore recommended that you enable the "Use all F1, F2, etc. keys as standard function keys" option [System Preferences > Keyboard].
  • Be sure to enable the Mac OS X 10.5+ keymap in Android Studio [Preferences > Keymap].
  • A fairly complete shortcut list can be found here.

Useful symbols: