Skip to content

Instantly share code, notes, and snippets.

View namchuai's full-sized avatar

NamH namchuai

View GitHub Profile
@benwalio
benwalio / uuid.jinja
Created August 11, 2021 16:45
create a basic uuid using jinja2
{%- set ns = namespace(uuid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') %}
{%- set ns.new_uuid = '' %}
{%- for x in ns.uuid %}
{%- set ns.new_uuid = [ns.new_uuid,(x | replace('x', [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f'] | random ))] | join %}
{%- endfor %}
{{ ns.new_uuid }}
@n0m0r3pa1n
n0m0r3pa1n / BottomSheetExtensions.kt
Last active October 2, 2023 01:53
Bottom sheet dialog with expanding and fullscreen display
fun Fragment.showBottomSheetDialog(
@LayoutRes layout: Int,
@IdRes textViewToSet: Int? = null,
textToSet: String? = null,
fullScreen: Boolean = true,
expand: Boolean = true
) {
val dialog = BottomSheetDialog(context!!)
dialog.setOnShowListener {
val bottomSheet: FrameLayout = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet) ?: return@setOnShowListener
@alkavan
alkavan / hardhat-openzeppelin-project.md
Created December 12, 2020 10:37
Hardhat and OpenZeppelin project bootstrap for Ethereum contract development

Install Instructions

Install Hardhat

npm install --save-dev hardhat

Initiate a new Hardhat project (in empty directory)

npx hardhat
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active March 26, 2024 20:38
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@madhums
madhums / install-android-emulator-brew-macos.md
Last active September 14, 2023 07:07
installing android emulator using cli on a mac

In your command line

brew install android-sdk --cask
sdkmanager "emulator"
sdkmanager "platform-tools"
sdkmanager "system-images;android-26;google_apis;x86_64"
avdmanager create avd -n NAME -k "system-images;android-26;google_apis;x86_64" # the one that you use above
@rylev
rylev / learn.md
Created March 5, 2019 10:50
How to Learn Rust

Learning Rust

The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.

Warning

Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.

The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.

@sts10
sts10 / alacritty.yml
Last active December 20, 2023 13:54
My Alacritty config yml for MacOS (compliant with v 0.4.1-dev)
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization.
#
# If this property is not set, alacritty will set it to xterm-256color.
#
@bruno78
bruno78 / scrim.xml
Created October 22, 2018 02:01
A scrim view to be added to the drawable folder, giving visibility to texts on white screen images
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="-90"
android:startColor="#00000000"
android:centerColor="#00000000"
android:endColor="#4d000000"
android:type="linear" />
</shape>
@nakov
nakov / secp256k1-example.js
Last active February 23, 2024 23:10
ECDSA in JavaScript: secp256k1-based sign / verify / recoverPubKey
let elliptic = require('elliptic');
let sha3 = require('js-sha3');
let ec = new elliptic.ec('secp256k1');
// let keyPair = ec.genKeyPair();
let keyPair = ec.keyFromPrivate("97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a");
let privKey = keyPair.getPrivate("hex");
let pubKey = keyPair.getPublic();
console.log(`Private key: ${privKey}`);
console.log("Public key :", pubKey.encode("hex").substr(2));