Skip to content

Instantly share code, notes, and snippets.

View laubstein's full-sized avatar

Thiago Laubstein laubstein

View GitHub Profile
@laubstein
laubstein / README.md
Last active December 26, 2023 18:10
Raspberry - Configurar APCUPSD

Raspberry - Configurar APCUPSD

Modelo de no-break testado: APC Back-UPS BX 1500BI-BR
Raspberry Pi: RPi 3 Model B+
SO: DietPi v8.25.1

Instalação dos Softwares Necessários

apt-get -y install apcupsd apcupsd-cgi lighttpd
@laubstein
laubstein / TrustStoreProvider.java
Created August 4, 2021 13:39
[java] demoiselle-signer - TrustStore Provider
package br.gov.example.demoiselle;
import org.demoiselle.signer.core.ca.provider.ProviderCA;
import org.demoiselle.signer.core.util.MessagesBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@laubstein
laubstein / run.sh
Created December 4, 2018 02:03
Photo and Video organized by dir
#!/usr/bin/bash
# JPG
find . -type f -iname "*.jpg" -print0 | xargs -0 -n1 -I % sh -c 'touch % -d "$(file %|grep -oP "datetime=\K[^,]*"|sed -e "s/:/-/"|sed -e "s/:/-/")"'
# MP4
find . -type f -iname "*.mp4" -print0 | xargs -0 -n1 -I % sh -c 'touch "%" -d "$(exiftool -s -s -s -CreateDate "%"|grep -oP "[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}"|grep -v 0000|sed -e "s/:/-/"|sed -e "s/:/-/")"'
# VID-20181028-WA0001.mp4
find . -type f -iname "VID-*-*.mp4" -print0 | xargs -0 -n1 -I % sh -c 'touch "%" -d "$(echo -n "%"|grep -oP "[0-9]{8}"|sed -r "s/([0-9]{4})([0-9]{2})([0-9]{2})/\1-\2-\3 12:00:00/")"'
@laubstein
laubstein / index.js
Last active December 4, 2017 23:37
Bacalhau para apurar evolução do nubank rewards
// data = resultado da chamada ao serviço que retorna os eventos
let data = require('./data/nubank_events.json');
let rewards_money = 0;
let rewards_points = 0;
let rewards_count = 0;
let hasReward = false;
let date = /^(.{10})T(.{8}).*$/;
let rewards_netflix = 2600;
function getDate(d) {
@laubstein
laubstein / atom-auto-update.sh
Last active August 23, 2016 01:27
Atom autoupdate
#!/bin/bash
dolog() {
logger -t atom-update "$*"
echo "$*"
}
dolog "Atom auto update started `date`"
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
MATCHEDROW=$(awk -F '[<>]' '/href=".*atom-amd64.deb/' /tmp/latest)
LATEST=$(echo $MATCHEDROW | grep -o -P '(?<=href=").*(?=" rel)')
@laubstein
laubstein / bash_progress.sh
Created May 13, 2016 11:49
Progressos em bash
#!/bin/bash
# from: http://stackoverflow.com/a/12500894
PROGRESS_COUNT=0
PROGRESS_TOTAL=100
PROGRESS_START=`date +%s`
while [ $PROGRESS_COUNT -lt $PROGRESS_TOTAL ]
do
# the code
sleep 0.5
@laubstein
laubstein / yo-completion.sh
Created April 16, 2015 13:01
Yeoman Available Generators Bash Completion
#!/bin/bash
_yo_complete()
{
local cur_word prev_word type_list
cur_word="${COMP_WORDS[COMP_CWORD]}"
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
type_list=`yo --help | tail -n+8`
// http://jsperf.com/padleft/2
/**
* String.repeat('a', 5) = 'aaaaa'
* String.repeat('ab', 5) = 'ababa'
* String.repeat('abc', 5) = 'abcab'
*/
String.repeat = function repeat(str, len) {
while (str.length < len) {
if (str.length * 2 >= len) {
return str + str.substring(0, len - str.length);