Skip to content

Instantly share code, notes, and snippets.

View namchuai's full-sized avatar

NamH namchuai

View GitHub Profile
@rjz
rjz / crypto-aes-256-gcm-demo.js
Last active March 11, 2024 20:11
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// The `iv` for a given key must be globally unique to prevent
@filipelenfers
filipelenfers / installJdkTarGzUbuntu.sh
Last active April 22, 2024 02:02
Install JDK from tar.gz Ubuntu
#Login as root
sudo su
#create jdk directory
mkdir /opt/jdk
#uncompress, change to your file name
tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
#check if files are there
@passiondroid
passiondroid / OpacityHex.markdown
Last active March 1, 2024 21:49
Opacity percentage in a Hex color code

Android uses hexadecimal ARGB values, which are formatted as #AARRGGBB. That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value. Here are the steps:

Alpha Hex Value Process

  • Take your opacity as a decimal value and multiply it by 255. So, if you have a block that is 50% opaque the decimal value would be .5. For example: .5 x 255 = 127.5

  • The fraction won't convert to hexadecimal, so you must round your number up or down to the nearest whole number. For example: 127.5 rounds up to 128; 55.25 rounds down to 55.

  • Enter your decimal value in a decimal-to-hexadecimal converter, like http://www.binaryhexconverter.com/decimal-to-hex-converter, and convert your values.

@rocketraman
rocketraman / .gitconfig
Last active January 17, 2024 01:52
.gitconfig aliases useful for gitworkflow (https://github.com/rocketraman/gitworkflow)
[alias]
# Basically `log --oneline --decorate --graph` with different colors and some additional info (author and date)
lg = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(normal)%s%C(reset) %C(dim white)%an%C(reset) %C(dim blue)(%ar)%C(reset) %C(dim black)%d%C(reset)'
# lg (see above) with --first-parent
lgp = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(normal)%s%C(reset) %C(dim white)%an%C(reset) %C(dim blue)(%ar)%C(reset) %C(dim black)%d%C(reset)' --first-parent
# https://stackoverflow.com/questions/61510067/show-specific-commits-in-git-log-in-context-of-other-commits
hl = "!f() { cd -- ${GIT_PREFIX:-.}; grep --color -E \"$(git log --pretty=%h \"$@\" | tr '\n' '|')\" || true; }; f"
hlp = "!f() { cd -- ${GIT_PREFIX:-.}; less -R -p $(git log --pretty=%h \"$@\" | tr '\n' '|'); }; f"
@aubricus
aubricus / License
Last active June 20, 2023 01:19
Python Progress Bar
Copyright 2020 Aubrey Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
@subfuzion
subfuzion / README.md
Last active April 11, 2024 14:52
vim/neovim configuration

I recently switched over to neovim (see my screenshots at the bottom). Below is my updated config file.

It's currently synchronized with my .vimrc config except for a block of neovim-specific terminal key mappings.

This is still a work in progress (everyone's own config is always a labor of love), but I'm already extremely pleased with how well this is working for me with neovim. While terminal mode isn't enough to make me stop using tmux, it is quite good and I like having it since it simplifies my documentation workflow for yanking terminal output to paste in a markdown buffer.

These days I primarily develop in Go. I'm super thrilled and grateful for fatih/vim-go,

@celso
celso / init.vim
Last active March 8, 2024 18:31
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
@michaellihs
michaellihs / tmux-cheat-sheet.md
Last active April 21, 2024 20:22
tmux Cheat Sheet
@nesquena
nesquena / SnappyRecyclerView.java
Last active June 21, 2023 23:04
Snap-to-Center RecyclerView Extension
// From: http://stackoverflow.com/a/37816976
public class SnappyRecyclerView extends RecyclerView {
// Use it with a horizontal LinearLayoutManager
// Based on http://stackoverflow.com/a/29171652/4034572
public SnappyRecyclerView(Context context) {
super(context);
}
@pandafulmanda
pandafulmanda / Python3 Virtualenv Setup.md
Last active March 12, 2024 15:59 — forked from akszydelko/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3