Skip to content

Instantly share code, notes, and snippets.

@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(
@valtoni
valtoni / mac_flutter_proto.sh
Created November 28, 2019 02:13
Install Protobuf at flutter on Mac
# Install protobuf
brew install protobuf
brew install swift-protobuf
flutter pub global activate protoc_plugin
echo '
# Flutter binaries
export FLUTTER_HOME="$HOME/work/apps/flutter"
export DART_HOME="$FLUTTER_HOME/bin/cache/dart-sdk"
export PATH="$PATH":"$FLUTTER_HOME/bin":"$FLUTTER_HOME/.pub-cache/bin":"$DART_HOME/bin"' > $HOME/.bashrc
@valtoni
valtoni / listfiles.awk
Created August 14, 2019 19:01
Display in kibibytes the sum of all files in current directory
ls -lap | grep -v / | awk '{
size = size + $5;
}
END {
print size/1024
}'
@echo off
SETLOCAL
if "%1%"=="" (
echo Please, fill JDK exe installer as first parameter
exit /B
)
set z7="C:\Program Files\7-Zip\7z.exe"
@valtoni
valtoni / generate_pks_company_keyrings.sh
Created April 2, 2019 22:57
Script to generate a lot of things: private, public key, certificates with SHA1 and SHA256 cyphers, pkcs12 keyrings with only these generated keys and full keyrings with company customized keychain
COMPANY_CERT=certnew
COMPANY_CERT_ORIGINAL=${COMPANY_CERT}.p7b
COMPANY_CERT_NAME=company_certificates.cer
COMPANY_CERT_PKCS7_DER=${COMPANY_CERT}.der.p7b
COMPANY_CERT_PKCS7_PEM=${COMPANY_CERT}.pem.p7b
PRIVATE_KEY=private
PRIVATE_KEY_LEN=2048
PUBLIC_KEY_EXPIRY_DAYS=365
PUBLIC_KEY=public
CERTIFICATE_REQUEST=request
@valtoni
valtoni / Exercise 6.4.lua
Last active November 1, 2018 16:33
Programming in Lua 4th edition. Chapter 6: Functions
-- Exercise 6.4: Write a function to shuffle a given list. Make sure that all permutations are equally probable.
function q4(...)
items = table.pack(...)
itemsr = {}
for i=1,#items do
math.randomseed(os.time())
pick = math.random(#items)
print("Picked item:", pick)
table.insert(itemsr,items[pick])
table.remove(items, pick)