Skip to content

Instantly share code, notes, and snippets.

View nayyaung's full-sized avatar

Nay Yaung nayyaung

View GitHub Profile
package com.example;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class AnagramWithAlternateVowel_1 {
private HashMap<Character, Integer> vowels ;
private HashMap<Character, Integer> consonents ;
@nayyaung
nayyaung / AnagramWithAlternateVowel_3.java
Last active May 2, 2022 14:06
Count anagram that starts with consonant and has no consecutive vowels
package com.example;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class AnagramWithAlternateVowel_3 {
private final int mod = 1000000007;
private HashMap<Integer, Integer> factMap;
@nayyaung
nayyaung / offline_package.sh
Last active April 19, 2022 04:21
Create offline apt package to install on Linux system without internet access
# Reference: https://stackoverflow.com/questions/22008193/how-to-list-download-the-recursive-dependencies-of-a-debian-package
# download the dependencies into a directory
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances <your-package-here> | grep "^\w" | sort -u)
# package them
dpkg-scanpackages . | gzip -9c > Packages.gz
# copy all downloaded *.deb and Packages.gz from previous step to your target machine
# create deb on target system without internet access
@nayyaung
nayyaung / database.rules.json
Created June 12, 2020 18:34 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@nayyaung
nayyaung / wrap_middleware.js
Created April 16, 2020 10:53
wrapping expressjs middleware
// SOURCE: https://stackoverflow.com/questions/47572752/calling-a-middleware-from-within-a-middleware-in-nodejs-expressjs
const wrappingMiddleware = (req, res, next) => {
try {
if (process.env.SOME_VAR === 'true') {
let externalMiddleware = logger({
custom:true
});
return externalMiddleware(req,res,next);
} else {
@nayyaung
nayyaung / jq-variable-slurp.sh
Last active December 27, 2019 09:33
Passing bash variable to jq for usage in slurp expression
jq --arg variable "$variable" -s '.[0] * .... "'$variable'" ... ' other-input-to-slurp
@nayyaung
nayyaung / delete-directory.ps1
Created September 3, 2018 06:51
Delete children folders recursively on Windows using powershell 5.1
get-childitem logs -path .\ -directory -recurse | remove-item -confirm:$false -recurse -force
@nayyaung
nayyaung / minikube script
Last active October 5, 2017 09:44
Starting minikube on Windows with Proxy
# first, download cntlm and setup proxy on local
minikube start --docker-env http_proxy=http://10.0.2.2:3128 --docker-env https_proxy=http://10.0.2.2:3128 --docker-env no_proxy=no_proxy=localhost,127.0.0.1,$YOUR_DOCKER_REPOSITORY$,10.160.170.30,10.0.0.0/24,192.168.99.0/24
# 10.0.2.2 is the gateway IP of minikube virtual box. "route -n" can be used to find out gateway.