Skip to content

Instantly share code, notes, and snippets.

View thiagosanches's full-sized avatar
🏠
Working from home

Thiago Sanches thiagosanches

🏠
Working from home
View GitHub Profile
@thiagosanches
thiagosanches / createMarkdownFromTelegramExportedChat.js
Last active February 5, 2023 12:35
A little nodejs script that load a JSON exported chat from Telegram, in order to get the links and create a markdown with them, so I can use them in LogSeq.
const fs = require('fs')
const axios = require('axios')
const myData = require('./result.json');
const regexTitleTag = /<title>(.*)<\/title>/g;
const regexRedditPost = /<meta property="og:title" content\=\"(.*?")/gm;
async function getContentFromURL(url) {
let html = null
try {
FROM ubuntu:20.04
RUN apt-get update && apt-get -y install sudo
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
RUN adduser --disabled-password --gecos '' guest
RUN adduser guest sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER guest
WORKDIR /home/guest
$0 = 10 (Step pulse time, microseconds)
$1 = 200 (Step idle delay, milliseconds)
$2 = 0 (Step pulse invert, mask)
$3 = 0 (Step direction invert, mask)
$4 = 0 (Invert step enable pin, boolean)
$5 = 0 (Invert limit pins, boolean)
$6 = 0 (Invert probe pin, boolean)
$10 = 3 (Status report options, mask)
$11 = 0.020 (Junction deviation, millimeters)
$12 = 0.002 (Arc tolerance, millimeters)
@thiagosanches
thiagosanches / main.tf
Last active March 30, 2022 11:21
Terraform recipe that creates loadbalancer and backend bucket
provider "google" {
project = "your-project-name"
}
# Create new storage bucket in the US region
# with coldline storage
resource "google_storage_bucket" "static_bucket" {
name = "${var.project}-${var.bucket_name}"
location = var.bucket_region
storage_class = "COLDLINE"
@thiagosanches
thiagosanches / aws-getter.sh
Last active October 3, 2021 15:18
aws-getter.sh
#!/bin/bash
# Run with source:
# source ./aws-getter.sh and you should be good - it will set your environment variable.
TEMP_FILE="/tmp/all-accounts.txt"
rm -rf $TEMP_FILE
cat ~/.aws/credentials | grep -E "\[.*?\]" | tr "[" " " | tr "]" " " | sort | uniq > $TEMP_FILE
INDEX=1
# create the timelapse
ffmpeg -r 10 -pattern_type glob -i "*.jpg" -vcodec libx264 output.mp4
while true
do
FILENAME=$(date +%Y%m%d-%H-%M-%S.jpg)
curl "http://192.168.15.11/cam-hi.jpg" -o "$FILENAME" --silent
gsutil cp $FILENAME "gs://esp32cam-timelapse/$FILENAME"
sleep 1;
rm $FILENAME
done
@thiagosanches
thiagosanches / git-revert-add-new-message.sh
Last active July 30, 2019 18:55
It's useful when you have to do some commits just to test, but it will not generate a lot of commit messages, since it's going "back" and generating a new commit
#!/bin/bash
# Important: Only use if you are working on a branch by yourself otherwise it will overwrite someone updates
git reset --soft HEAD~1 \
&& git add . && git commit -m "$1" \
&& git push --force origin