Skip to content

Instantly share code, notes, and snippets.

View dgacitua's full-sized avatar

Daniel Gacitúa dgacitua

View GitHub Profile
@dgacitua
dgacitua / aliases\Logitech_G923_TRUEFORCE_Racing_Wheel_PS_USB.xml
Created February 22, 2024 18:21 — forked from qcho/aliases\Logitech_G923_TRUEFORCE_Racing_Wheel_PS_USB.xml
City Car Driving Preset - Logitech G923 TRUEFORCE Racing Wheel PS
<?xml version="1.0"?>
<Alias targetDevice1="Logitech G923 TRUEFORCE Racing Wheel PS USB"
targetDevice2="Logitech G923 TRUEFORCE Racing Wheel PS"
targetProductGuid="{C266046D-0000-0000-0000-504944564944}">
<Axis axis="x" name="Steering" />
<Axis axis="y" name="Gas" />
<Axis axis="rz" name="Brake" />
<Axis axis="slider:0" name="Clutch" />
<Button number="1" name="X" />
<Button number="2" name="Square" />
@dgacitua
dgacitua / backupExternalMedia.sh
Created November 25, 2023 14:51
Bash script to backup a mounted external drive to local folder
#!/bin/bash
set -e
SOURCE="/media/dgacitua/DGACITUA-SSD/" # Mounted external drive path (including trailing slash)
DESTINATION="/home/dgacitua/rsync-backup" # Local folder where the data is copied (without trailing slash)
mkdir -p $DESTINATION
rsync -azuvhP --delete --exclude="node_modules" --iconv=. $SOURCE $DESTINATION # Making backup with RSync
@dgacitua
dgacitua / sshTunnel.sh
Created November 25, 2023 14:43
Bash script to deploy a SSH Tunnel from remote server to local machine
#!/bin/bash
# Customize the following variables
REMOTE_USERNAME=myuser # Remote server username
REMOTE_HOST=server.myuser.info # Remote server domain or IP address
REMOTE_PORT=4000 # Remote server port to redirect
LOCAL_PORT=3000 # Local machine port where the remote port is redirected
echo -e "Tunneling to $REMOTE_HOST from remote port $REMOTE_PORT to local port $LOCAL_PORT"
@dgacitua
dgacitua / caret-svm-spectrumkernel.R
Created February 25, 2023 13:58
Custom implementation of SVM Spectrum String Kernel for caret in R
library(kernlab)
spectrumSVM <- list(type = "Classification", library = "kernlab", loop = NULL)
spectrumSVM$parameters <- data.frame(parameter = c("C", "length"), class = c("numeric", "numeric"), label = c("Cost", "length"))
spectrumSVM$grid <- function(x, y, len = NULL, search = "grid") {
if (search == "grid") {
out <- expand.grid(length = 2:(len+1), C = 2^((1:len)-3))
} else {
@dgacitua
dgacitua / rsync-backup.sh
Created August 20, 2022 20:15
Bash script to backup remote server's home directory to local folder
#!/bin/bash
# https://gist.github.com/spyesx/0edd62936600ffe7ca0b5c27bc7d080c
# https://explainshell.com/explain?cmd=rsync+-azuvhP+--delete+--exclude%3D%22node_modules%22
set -e
# Replace SOURCE and DESTINATION values to match your needs
SOURCE="remoteuser@mydomain.info:/home/remoteuser/"
DESTINATION="/home/localuser/rsync-backup"
@dgacitua
dgacitua / nginx-reverse-proxy.conf
Last active October 5, 2021 23:45
Simple Nginx reverse proxy
server {
listen 80;
server_name myapp.org;
error_log /var/log/nginx/myapp.error.log warn;
client_max_body_size 50M;
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@dgacitua
dgacitua / crontab
Created July 27, 2021 20:29
MongoDB backup cronjob (files will be saved on ~/backups)
# Run "crontab -e" and add the uncommented lines at the end of the file
# Be sure to put the absolute path of mongobackup.sh
# This job will run every Saturday at 01:00
0 1 * * 6 ./home/myuser/mongobackup.sh
@dgacitua
dgacitua / keydetect2.py
Created May 18, 2021 16:46
KeyUp/Keydown logger in Python3 for Linux (writes to CSV file)
# KeyUp/Keydown logger in Python3 (writes to CSV file)
# Based on https://blog.robertelder.org/detect-keyup-event-linux-terminal/
import signal
import re
import struct
import select
import os
import subprocess
import csv
@dgacitua
dgacitua / keydetect.py
Last active May 18, 2021 16:47
Local KeyUp/Keydown logger in Python3 for Linux (outputs to terminal)
# KeyUp/Keydown logger in Python3 (outputs to terminal)
# Based on https://blog.robertelder.org/detect-keyup-event-linux-terminal/
import signal
import re
import struct
import select
import os
import subprocess
@dgacitua
dgacitua / nginx-html-secure.conf
Created March 20, 2021 19:39
Nginx configuration file for a static HTML server using a secure connection with Let's Encrypt
server {
listen 80;
server_name mydomain.org www.mydomain.org;
return 301 https://mydomain.org$request_uri;
}
server {
listen 443 ssl default_server;
server_name mydomain.org www.mydomain.org;