Skip to content

Instantly share code, notes, and snippets.

cat >/tmp/demo-space-separated.sh <<'EOF'
#!/bin/bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-e|--extension)
@valtoni
valtoni / mount_ec2_ephemeral.sh
Last active February 25, 2021 20:50
This script automatically mount ephemeral disks in EC2 nitro instances.
#!/usr/bin/env bash
# Mandatory: apt install nvme-cli
# Mount point (directory)
TARGET_MOUNT=/data/tmp
# Raid info
TARGET_RAID_DEVICE=/dev/md0
TARGET_RAID_LABEL=RAID0
@valtoni
valtoni / xcode_uninstall.sh
Last active November 3, 2020 23:10
Remove Xcode
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
dirs = ("$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
"$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
/Applications/Xcode.app
~/Library/Caches/com.apple.dt.Xcode
@valtoni
valtoni / slack.sh
Created September 12, 2020 20:39 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@valtoni
valtoni / path_environment.ps
Created June 19, 2020 12:55
Set path environment on windows powershell
# Add path permanently to environment machine
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", "Machine")
# Add path permanently to environment user
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", "User")
@valtoni
valtoni / symb_notepad.ps
Created June 18, 2020 14:18
Create symbolic link to notepad++ on windows
cmd /c mklink "$LOCALAPPDATA\Microsoft\WindowsApps\edit" "C:\Program Files (x86)\Notepad++\notepad++.exe"
// val e = (1 to 10 toList).mkString(",")
import org.apache.spark.sql.types._
import org.apache.spark.sql.types.{DoubleType, StringType, StructField, StructType}
import org.apache.spark.sql.{Row, SparkSession}
// 2019-12-10 16:06:40,135 cask datab 0012 REST TRACE [com.kortlet.IEnferinend] (ajp-/192.168.0.1:8009-77) Invoke End
val regexRestBase = """(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3})[\s\t]+(\w+)[\s\t]+(\w+)[\s\t]+(\d+)[\s\t]+(\w+)[\s\t]+(\w+)[\s\t](\[[\w\.]+\])[\s\t]+(\(.*\))[\s\t]+(.*)""".r
@valtoni
valtoni / dump-java.sh
Created June 4, 2020 11:16
Full dump of program in jdk
#!/bin/bash
LOCAL_DIR=~/
PROGRAM_NAME=my-jar-exe
HOST=$(hostname | cut -d "." -f 1)
PROGRAM_PIDS=$(jps -v | grep $PROGRAM_NAME | cut -d " " -f 1)
function insert_sqlite {
FILE=$2
@valtoni
valtoni / spendee_downloadbutton_csv.js
Created January 18, 2020 22:48
spendee.com: Download csv with transactions loaded in screen (greasemonkey)
// ==UserScript==
// @name Spendee Button Donwload CSV
// @version 0.1
// @description Download CSV transactions
// @match https://app.spendee.com/wallet/*/transactions
// @copyright 2020+, Valtoni Boaventura
// ==/UserScript==
console.info("CSV Button foi ativado para a página");
static <T, E extends Exception> Consumer<T> handlingConsumerWrapper(
ThrowingConsumer<T, E> throwingConsumer, Class<E> exceptionClass) {
return i -> {
try {
throwingConsumer.accept(i);
} catch (Exception ex) {
try {
E exCast = exceptionClass.cast(ex);
System.err.println(