Skip to content

Instantly share code, notes, and snippets.

@ivawzh
ivawzh / Windows-bash.md
Last active April 17, 2023 06:02
Windows sub-system bash setup

New way

  1. Install "Windows terminal" from Microsoft store
  2. install WSL: wsl --install https://learn.microsoft.com/en-us/windows/wsl/install#update-to-wsl-2
  3. Change default tab to Ubuntu: Settings -> Startup -> Default Profile -> Ubuntu
  4. Install Code by running in terminal: $ code
  5. set up github access: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=linux
  6. Install Homebrew https://linux.how2shout.com/install-brew-on-wsl-windows-subsystem-for-linux/. And make sure follow the Next steps instruction.
  7. Install zsh: $ brew install zsh. Start zsh on every terminal session start: sed -i '$a\\n# Start oh-my-zsh\nif test -t1; then\n exec zsh\nfi' .profile
  8. Install ohmyzsh $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@ivawzh
ivawzh / catch-a-catch.js
Last active November 2, 2016 22:24
Javascript .reject in .catch will not be caught in the other .catch
describe.only('catch of catch', () => {
it('does not catches error as expected', done => {
function errra () {
return new Promise((resolve, reject) => {
reject(3)
})
}
Promise.resolve()
@ivawzh
ivawzh / install_on_Ubuntu_on_windows.bash
Last active March 3, 2017 10:39
Install Elixir and Erlang
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install esl-erlang=1:18.3
sudo rm /usr/bin/erl
sudo ln -s /usr/lib/erlang/bin/erl /usr/bin/erl
sudo apt-get install elixir
@ivawzh
ivawzh / ALB-template.yaml
Created February 24, 2017 01:38
Stand alone ALB Cloudformation setup. For ECS service to consume.
Resources:
# ============================ Application Load Balancer ============================
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref AWS::StackName
Scheme: internet-facing
Subnets: !Split
@ivawzh
ivawzh / decrypt_kms.bash
Last active February 26, 2017 07:40
Bash helper function that decrypts Base64 encoded KMS secret.
function decrypt_kms {
if [ "$#" -ne 1 ]; then
echo "Please provide base64 encoded kms-secret (aka. ciphertext-blob), e.g. decrypt_kms aasd123123lkjklj"
else
echo $(aws kms decrypt \
--ciphertext-blob fileb://<(echo "$1" | base64 -d) \
--output text \
--query Plaintext | base64 --decode
)
fi
@ivawzh
ivawzh / Docker-on-bash-on-Ubuntu-on-Windows-10.md
Last active October 4, 2018 13:56
setup Docker on bash on Ubuntu on Windows 10
@ivawzh
ivawzh / export_psql_csv_via_ssh.md
Last active March 15, 2017 05:49
download file via ssh & psql

login to server in private subnet hence we can talk to db:

ssh example_server

connect database

psql example_db_url -U example_user example_database
@ivawzh
ivawzh / countries.sql
Created March 26, 2017 15:14 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@ivawzh
ivawzh / login.js
Last active April 18, 2017 02:06
Redux Login Action snippet
// @ redux/actions/login.js
export function loginStart(username, pw): Promise<void> {
return async (dispatch) => {
dispatch({ type: 'LOGIN_START' })
try {
const userData = await login(username, pw)
dispatch(loginSuccess(userData))
} catch (error) {
dispatch(loginFailure(error))
}