Skip to content

Instantly share code, notes, and snippets.

View niradler's full-sized avatar
🎮

Nir Adler niradler

🎮
View GitHub Profile
# shellman options
# Usage: options=("one" "two" "three"); inputChoice "Choose:" 1 "${options[@]}"; choice=$?; echo "${options[$choice]}"
function inputChoice() {
echo "${1}"
shift
echo $(tput dim)-"Change option: [up/down], Select: [ENTER]" $(tput sgr0)
local selected="${1}"
shift
ESC=$(echo -e "\033")
@niradler
niradler / awsclidriver.py
Created July 26, 2021 16:20
python aws cli driver
import os
if os.environ.get('LC_CTYPE', '') == 'UTF-8':
os.environ['LC_CTYPE'] = 'en_US.UTF-8'
from awscli.clidriver import create_clidriver
driver = create_clidriver()
driver.main('s3 mv source_bucket target_bucket --recursive'.split())
@niradler
niradler / npm-install-all.sh
Created February 18, 2021 17:25
find and install npm packages in a mono repo.
npm i -g strin loop-pipe
find . -name package.json | grep -v node_modules | strin replace --t="package.json" --v="" --sr="ig" | lp "(cd {v} && npm i)"
@niradler
niradler / Makefile
Created February 15, 2021 07:11
Makefile for go projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)
substitutions:
devicename: ttgocam
friendly_name: test esp32cam
ip_address: 192.168.1.230
esphome:
name: $devicename
platform: ESP32
board: esp-wrover-kit
@niradler
niradler / backup.js
Last active August 28, 2020 13:34
backup memex data using chrome snippet.
var dbName = 'memex';
var version = 1;
var conn = indexedDB.open(dbName, version) // change the name and version as needed
function exportToJson(idbDatabase) {
return new Promise((resolve, reject) => {
const exportObject = {}
if (idbDatabase.objectStoreNames.length === 0) {
resolve(JSON.stringify(exportObject))
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
@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
@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 / 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 {