Skip to content

Instantly share code, notes, and snippets.

@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active May 8, 2024 05:28
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@Siddhant-K-code
Siddhant-K-code / til-8-may-2024.md
Created May 8, 2024 04:34
TIL (05/08/2024): DynamoDB Query Evaluation Order Differs from SQL

DynamoDB Query Evaluation Order Differs from SQL

Summary:

When using LIMIT in DynamoDB queries, the order of evaluation can differ from SQL queries, potentially leading to unexpected results depending on the search criteria used.

SQL Query Evaluation Order:

SQL queries follow a specific order of evaluation:

FROM -> ON -> JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> DISTINCT -> ORDER BY -> LIMIT
@tomasevich
tomasevich / remove-all-from-docker.md
Last active May 8, 2024 05:19 — forked from beeman/remove-all-from-docker.sh
Удалить/очистить все данные Докера (контейнеры, образы, тома и сети)

Удалить/очистить все данные Докера (контейнеры, образы, тома и сети)

Одной строкой

docker stop $(docker ps -qa) && docker rm $(docker ps -qa) && docker rmi -f $(docker images -qa) && docker volume rm $(docker volume ls -q) && docker network rm $(docker network ls -q)

Описание команд

Instructions for a mac on how to play with pyenv and poetry

Why both? Pyenv to manage multiple python versions. You can make virtualenvs with pyenv of course, but using poetry will simplify that process

# Install pyenv.
brew install pyenv

# Add pyenv initializer to shell startup script.
echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then
@0xjac
0xjac / private_fork.md
Last active May 8, 2024 05:12
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocksConfig version="1">
<editor>
<colour_sets>
<ACTIVE_COLOUR_SET>
<str>
<![CDATA[modnokai night shift v2]]>
</str>
</ACTIVE_COLOUR_SET>
<ACTIVE_LANG>
#!/usr/bin/python
#!/usr/bin/env python
import os
import glob
import time
import RPi.GPIO as GPIO
import sys, getopt
import decimal
@Everlanders
Everlanders / ButtonMonitor.py
Last active May 8, 2024 05:09
Python Script to monitor GPIO button presses and call the Camera and Backlight.
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess, os
import signal
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
RearView_Switch = 14 # pin 18
Brightness_Switch = 15 # pin 16
@Everlanders
Everlanders / backlight.sh
Created March 6, 2018 15:16
Script to Change the Backlight brightness on the Official Raspberry Pi 7" display.
#!/bin/bash
level=$1
#echo "level given is $level"
if [ $# != 1 ]; then
echo "USAGE: $0 brightness_level (0 to 255)"
exit 1
fi
@Everlanders
Everlanders / LightMonitor.py
Created March 13, 2018 14:47
Headlight and Reverse Lights monitor for YouTube Commenters - UNTESTED but should work fine.
#!/usr/bin/python
# A quick hack of my button monitor script to monitor headlights and reverse lights to
# Dim the screen and switch to the reverse camera.
# I have not tested this...
# Remember, the switch or opto is switching to ground, so the logic is inverted... 0 = on 1 = off
# Also, you would run only one of these "Monitor" scripts. you can't be running RearviewMonitor.py AND LightMonitor.py
import RPi.GPIO as GPIO
import time
import subprocess, os