Skip to content

Instantly share code, notes, and snippets.

@phatnhse
phatnhse / HMAC.java
Created March 7, 2018 08:06 — forked from MaximeFrancoeur/HMAC.java
Generating HMAC MD5/SHA1/SHA256 etc in Java
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class HMAC {
public static void main(String[] args) throws Exception {
System.out.println(hmacDigest("The quick brown fox jumps over the lazy dog", "key", "HmacSHA1"));
}
@phatnhse
phatnhse / .gitignore
Last active June 11, 2018 04:34
Git ignore android
# Get from this link: https://github.com/github/gitignore/blob/master/Android.gitignore
.DS_Store
/app/release/*.*
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
@phatnhse
phatnhse / remove_local_branch.sh
Last active July 12, 2018 04:06
Remove all local branch except "develop"
branches=$(git branch | tr -d " *")
output=""
for branch in $branches
do
if [[ $branch != "develop" ]]; then
output="$output $branch"
fi
done
git branch -d $output
@phatnhse
phatnhse / iterm2-solarized.md
Created August 22, 2018 04:15 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@phatnhse
phatnhse / BitmapUtils.kt
Last active September 8, 2018 12:50
BitmapUtils for java/android developement (written with Kotlin
object BitmapUtils {
private const val MAX_HEIGHT = 1280.0f
private const val MAX_WIDTH = 1280.0f
fun getScaledBitmap(bm: Bitmap,
bmOriginalWidth: Int,
bmOriginalHeight: Int,
originalWidthToHeightRatio: Double,
originalHeightToWidthRatio: Double,
maxHeight: Int,
@phatnhse
phatnhse / rails http status codes
Created April 15, 2019 11:46 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@phatnhse
phatnhse / pull_request_template.md
Last active May 24, 2021 15:43
Pull Request Template

[WIP] [#FBI-23] Add a button for environment selection

  • Add a spinner in splash screen
  • Update env configuration
  • Add tests

Screenshot or video goes here

FROM adoptopenjdk/openjdk8:alpine
WORKDIR /
SHELL ["/bin/sh", "-c"]
RUN apk update && apk upgrade && apk add --no-cache bash git unzip wget libvirt-daemon qemu-img qemu-system-x86_64 dbus polkit virt-manager
# gradle caching
ENV GRADLE_USER_HOME=/cache
@phatnhse
phatnhse / postgres-cheatsheet.md
Created October 18, 2022 08:21 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
resource "aws_ecs_task_definition" "my_simple_task" {
family = "my-task"
container_definitions = <<DEFINITION
[
{
// other configurations
"memory": 512,
"cpu": 256
}
]