Skip to content

Instantly share code, notes, and snippets.

View theagoliveira's full-sized avatar

Thiago Cavalcante theagoliveira

View GitHub Profile
*.svg
*.html
@theagoliveira
theagoliveira / bash_to_powershell.md
Created March 17, 2022 15:36
Bash commands and its equivalents in Powershell

Bash to Powershell

Bash Powershell Source
touch filename echo $null >> filename Source
@theagoliveira
theagoliveira / EdgeNode.java
Created November 18, 2021 04:44
A graph implementation in Java, based on The Algorithm Design Manual by Steven S. Skiena
package impl.graph;
class EdgeNode {
Integer y; /* adjacency info */
Integer weight; /* edge weight, if any */
EdgeNode next; /* next edge in list */
public EdgeNode(Integer y) {
this.y = y;
@theagoliveira
theagoliveira / copy_latex_dirs.sh
Last active January 25, 2022 05:34
Recreate LaTeX project directory structure inside build folder
#!/usr/bin/env bash
# SOURCE: https://tex.stackexchange.com/questions/323820/i-cant-write-on-file-foo-aux/485273#485273
# find all directories which are not the destination dir or inside it
find "$1" -maxdepth 1 -type d -not -name "$2" -not -path "$1/$2/*" -not -path "$1" -printf '%P\n' \
| while IFS= read -r dir
do
cp -r "$1/$2/${2}_$3/$dir" "$1/$2"
done
@theagoliveira
theagoliveira / .geeks_for_geeks
Last active July 28, 2021 21:28
GeeksforGeeks questions
We couldn’t find that file to show.
@theagoliveira
theagoliveira / dryrun_wp_msg_bkp.sh
Created July 19, 2021 20:43
WhatsApp messages backup scripts
#!/usr/bin/env zsh
old="$1"
new="$2"
olddate=$(echo "$old" | sed -re "s/^.*?([0-9]{4}-[0-9]{2}-[0-9]{2})\.txt/\\1/g")
newdate=$(tail -1 "$new" | sed -re "s/^([0-9]*)\\/([0-9]*)\\/([0-9]*).*/20\\3-\\1-\\2/g" | sed -re "s/-([0-9])-/-0\\1-/g" | sed -re "s/-([0-9])$/-0\\1/g")
echo $old
echo $new
echo $olddate
# 1
qrencode -t utf8 'WIFI:T:WPA;S:network;P:password;;'
# 2
read -rp "SSID: " ssid
read -rsp "Password: " pass
echo -e "\n"
qrencode -t utf8 "WIFI:T:WPA;S:$ssid;P:$pass;;"
@theagoliveira
theagoliveira / custom-java-profile.xml
Last active May 13, 2021 05:05
Custom Java formatter profile for Eclipse / Spring Tool Suite / Visual Studio Code (xml and prefs)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="20">
<profile kind="CodeFormatterProfile" name="Thiago" version="20">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
@theagoliveira
theagoliveira / iterate_files.sh
Created April 15, 2021 06:24
Recursively iterate through files in a directory
# SOURCE: https://unix.stackexchange.com/a/139381/454027
while IFS= read -r -d '' -u 9
do
echo "Filename is '$REPLY'"
done 9< <( find "PATH" -regex ".*\.EXTENSION" -exec printf '%s\0' {} + )