Skip to content

Instantly share code, notes, and snippets.

View niradler's full-sized avatar
🎮

Nir Adler niradler

🎮
View GitHub Profile
@niradler
niradler / aws_clear_old_lambda_versions.js
Created June 2, 2019 20:31
How to Free AWS Lambda Code Storage (CodeStorageExceeded)
const execa = require("execa");
const fs = require("fs");
const awsCliGetCmd = ({ FunctionName = "", Version = "" }) => ({
"list-functions": `aws lambda list-functions`,
"list-versions-by-function": `aws lambda list-versions-by-function --function-name ${FunctionName}`,
"delete-function": `aws lambda delete-function --function-name ${FunctionName} --qualifier ${Version}`
});
const run = async cmd => {
@niradler
niradler / git-submodules.md
Created June 29, 2019 10:49 — forked from u840903/git-submodules.md
Github Submodule Cheat Sheet

Add a submodule

git submodule add https://github.com/janjarfalk/canvasrunner.git components/canvasrunner/

Update all submodules

git submodule foreach git pull origin master
cd ..
git commit . -m "Updated submodules"
#!/bin/bash
# configure env variable STAGE, OLDPWD
# run command in each folder
set -e
for path in $(ls projects); do
if [[ -d "projects/$path" ]]
then
echo "deploying $path"
@niradler
niradler / create-new-repo.sh
Created July 21, 2019 21:46
create new github repo with bash. ./create-new-repo.sh {repo name} [path]
#!/bin/bash
# https://medium.com/better-programming/create-github-repos-remotely-25153a6e6890
# GitHub API Token
GH_API_TOKEN=''
# GitHub User Name
GH_USER=''
# Variable to store first argument to setup-repo, the repo name. Will be used as GH repo name, too.
NEW_REPO_NAME=$1
# Store current working directory.
CURRENT_DIR=$PWD
const logform = require('logform');
const tripleBeam = require('triple-beam');
const winston = require('winston');
const errorHunter = logform.format(info => {
if (info.error) return info;
const splat = info[tripleBeam.SPLAT] || [];
info.error = splat.find(obj => obj instanceof Error);
@niradler
niradler / win_setup_for_developers.bat
Last active January 10, 2020 13:19
A script to run after a fresh windows installation to setup an environment for developers. (run in administrator shell)
# install chocolatey (win pkg manager like apt or brew)
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# install programing languages
choco install -y python3 golang nodejs # nvm instead of nodejs is a good option
# install apps
choco install -y vscode googlechrome 7zip.install vlc notepadplusplus.install git.install winscp curl putty
# install vm
@niradler
niradler / main.tf
Created April 2, 2020 18:29
terraform set domain record according to domain mapping
# Domain mapping
resource "google_cloud_run_domain_mapping" "default" {
location = "us-east1"
name = var.domain
metadata {
namespace = var.projectId
}
spec {
@niradler
niradler / startup.sh
Last active April 30, 2020 22:27
startup script to setup new vm with docker and docker compose.
sudo apt update
sudo apt upgrade
free -h
df -h
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
@niradler
niradler / port.sh
Created May 1, 2020 15:18
fix port issue on linux
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
# or
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 900 -j REDIRECT --to-port 3000
chsh -s /bin/bash
sudo apt-get update
sudo apt upgrade
sudo apt install zsh
sudo apt-get install powerline fonts-powerline
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc