Skip to content

Instantly share code, notes, and snippets.

@etigui
etigui / rpi_config_samba.md
Last active May 1, 2019 20:10
Setup samba server on Raspberry PI 3B with share mounted storage

Configuration of the Raspberry Pi

Once you have all the necessary equipment, the Raspberry is running and you are connected in SSH, you can start by updating your Raspberry Pi.

sudo apt update 
sudo apt upgrade

Once the updates are complete, create the folder that will be accessible on the samba server.

$> mkdir /home/pi/shares
@etigui
etigui / ssh_login_attempts.md
Last active October 7, 2018 07:26
View SSH Login Attempts

View your System’s Authorization Log

To view your systems authorization log simply type the following command in a terminal window:

$> cat /var/log/auth.log

View Failed SSH Login Attempts

To view all your failed login attempts type the following command into a terminal window:

@etigui
etigui / rpi_config_fail2ban.md
Last active October 24, 2021 22:38
Install Fail2Ban on the Raspberry Pi

Install fail2ban

Update and install Fail2Ban by typing the following commands:

$> sudo apt-get update
$> sudo apt-get install fail2ban

Edit SSH Fail2Ban configurations. Open up the "/etc/fail2ban/jail.local" file with the following command (jail.local file should be empty):

$> sudo nano /etc/fail2ban/jail.local
@etigui
etigui / rpi_stream_cam_vlc.md
Last active October 7, 2018 13:03
Stream Raspberry PI camera flow with RTP/RTSP using VLC

Serveur

 raspivid -fps 25 -vf -n -t 0 -o - | cvlc -vvv stream:////dev/stdin --sout '#rtp{sdp=rtsp://8554/}' :demux=h264

Configuration:

  • vf: flips captur vertical
  • n: no preview
  • t: duration of capture (infinite)
  • o: Output (subsequent pipe)
@etigui
etigui / rpi_stream_cam_gstreamer.md
Last active October 7, 2018 13:02
Stream Raspberry PI camera flow with GStreamer

Serveur

 raspivid -fps 25 -h 720 -w 1080 -vf -n -t 0 -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.1.100 port=5000

Configuration:

  • h and w: video capture resolution
  • vf: flips captur vertical
  • n: no preview
  • t: duration of capture (infinite)
  • b: stream bitrate (2Mb/s)
@etigui
etigui / rpi_stream_cam_netcat.md
Last active October 7, 2018 13:02
Stream Raspberry PI camera flow over netcat connection

Client

$> ./rpi_stream_cam_netcat_client.sh

Server

$> raspivid -vf -n -o - -t 0 -b 2000000  | nc 192.168.1.100 5777

Lunch OpenCV exemple, which reads the named pipe like regular h264 file

@etigui
etigui / .htaccess
Last active November 24, 2018 09:31
Htaccess redirect HTTP to HTTPS without "too many redirects" error
# http to https redirect
# https://stackoverflow.com/questions/43743283/htaccess-rewrite-too-many-redirects
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://exemple.com%{REQUEST_URI} [L,NE,R=301]
@etigui
etigui / dico.py
Last active November 24, 2018 09:31
Python how to merge two dictionaries in Python 3.5+ (PyTricks)
# How to merge two dictionaries
# in Python 3.5+
>>> x = {'a': 1, 'b': 2}
>>> y = {'b': 3, 'c': 4}
>>> z = {**x, **y}
>>> z
{'c': 4, 'a': 1, 'b': 3}
@etigui
etigui / multiple_flag.py
Last active November 24, 2018 09:31
Python different ways to test multiple flags at once in Python (PyTricks)
# Different ways to test multiple
# flags at once in Python
x, y, z = 0, 1, 0
if x == 1 or y == 1 or z == 1:
print('passed')
if 1 in (x, y, z):
print('passed')
@etigui
etigui / dict_default.py
Last active November 10, 2018 09:40
Python default argument return when "get()" is called if the given key not exists in the dict (PyTricks)
# The get() method on dicts
# and its "default" argument
name_for_userid = {
382: "Alice",
590: "Bob",
951: "Dilbert",
}
def greeting(userid):