Skip to content

Instantly share code, notes, and snippets.

View caputomarcos's full-sized avatar
👽
ping!

Marcos Caputo caputomarcos

👽
ping!
View GitHub Profile
@caputomarcos
caputomarcos / fix-wsl2-dns-resolution
Created October 4, 2024 19:37 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@caputomarcos
caputomarcos / MQTT_Node-Red_Influx.md
Created August 18, 2024 22:15 — forked from Paraphraser/MQTT_Node-Red_Influx.md
Efficient recipe for getting MQTT data into an InfluxDB database using Node-Red

Recipe: from MQTT to InfluxDB via Node-RED

  • 2024-05-16 adds case study explaining how to extract values from topic strings, and how to specify the measurement name in the message payload provided to the "influxdb out" node.
  • 2023-12-02 revise graphics to correspond with "influxdb out" node, and explain the pros and cons of InfluxDB 1.8 vs InfluxDB 2.

Introduction

Getting data produced by IoT sensors into a database is practically a mandatory step before effective visualisation (eg dashboards).

This recipe shows you how to get an MQTT payload into an InfluxDB database using three Node-RED nodes. It makes the following assumptions:

@caputomarcos
caputomarcos / qvm-filemanager.pl
Created March 17, 2023 22:05 — forked from 100111001/qvm-filemanager.pl
Qubes OS: Opens a file manager in the focused VM
#!/usr/bin/env perl
use strict;
use warnings;
sub open_file_manager {
my $vm = shift;
exec {'qvm-run'} ('qvm-run', '--', $vm, 'exec nautilus --new-window --no-desktop </dev/null >/dev/null') or die "qvm-run exec failed\n";
}
@caputomarcos
caputomarcos / listchars.vim
Created May 4, 2022 14:51 — forked from while0pass/listchars.vim
show/hide hidden characters in Vim
" hide hidden chars
:set nolist
" show hidden characters in Vim
:set list
" settings for hidden chars
" what particular chars they are displayed with
:set lcs=tab:▒░,trail:▓,nbsp:░
" or
@caputomarcos
caputomarcos / Docker: save_load_compressed_container.bash
Created March 21, 2022 22:08 — forked from lsauer/Docker: save_load_compressed_container.bash
Docker: save/load container using tgz file (tar.gz)
#for an image ("not running container") use save:
docker save <dockernameortag> | gzip > mycontainer.tgz
#for running or paused docker, use export:
docker export <dockernameortag> | gzip > mycontainer.tgz
#load
gunzip -c mycontainer.tgz | docker load
@caputomarcos
caputomarcos / start_rssh_tunnel.sh
Created March 17, 2022 20:00 — forked from volkstrader/start_rssh_tunnel.sh
Start reverse ssh tunnel for cron job
#!/bin/bash
SSH_REDIR_PORT=12345
SSH_D="cloud_sshd"
COMMAND="ssh -R $SSH_REDIR_PORT:localhost:22 $SSH_D -N -f"
pgrep -f "ssh -R $SSH_REDIR_PORT:localhost:22" > /dev/null 2>&1 || (eval $COMMAND && echo $COMMAND)
@caputomarcos
caputomarcos / decompile_java.md
Last active February 10, 2022 20:23
Decompile Java class or Jar container under Linux Mint / Ubuntu

Lee Benfield's Java decompiler CFR is straight forward and can even batch decompile jar container. 

  1. Download the most recent version of CFR (crf 0.1.15 at the time of writing)
wget http://www.benf.org/other/cfr/cfr_0_115.jar
  1. Run decompile with output into terminal
java -jar cfr_0_115.jar javaclasstodecompiles.class
@caputomarcos
caputomarcos / README.md
Created February 5, 2022 15:35 — forked from cerebrate/README.md
Recompile your WSL2 kernel - support for snaps, apparmor, lxc, etc.

NOTE

See https://gist.github.com/cerebrate/d40c89d3fa89594e1b1538b2ce9d2720#gistcomment-3563688 below before doing anything else.

Recompile your WSL2 kernel - support for snaps, apparmor, lxc, etc.

Yes, I've done this, and yes, it works. It is, however, entirely unsupported and assembled through reasonable guesswork, so if you try this and it explodes your computer, brain, career, relationships, or anything else, you agree that you take sole responsibility for doing it, that I never claimed it was a good idea, and that you didn't get these instructions from me .

@caputomarcos
caputomarcos / README.md
Created December 5, 2021 01:04 — forked from doino-gretchenliev/README.md
Node-RED Radius custom authentication and authorization. #node-red #nodered #radius #authentication #javascript

Node-RED Radius custom authentication and authorization

Requirements

Installation

  1. Save user-authentication.js to <node-red>/user-authentication.js.
  2. Add the following line to setting.js:
@caputomarcos
caputomarcos / ps1.py
Created May 30, 2019 03:14 — forked from webstory/ps1.py
Python and Nodejs with subprocess
#-*- coding: utf-8 -*-
import subprocess
if __name__ == '__main__':
ps = subprocess.Popen(['nodejs','ps2.js'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out = ps.communicate(input='http://www.daum.net'.encode())[0]
print(out.decode('utf-8'))