Skip to content

Instantly share code, notes, and snippets.

View poulou0's full-sized avatar
🍋

Poulou poulou0

🍋
View GitHub Profile
@poulou0
poulou0 / pem_key_generators.md
Created October 14, 2022 07:11
Asymetric PEM keypair generators with PHP and Node.js

PEM format https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail

PHP

OPENSSL_KEYTYPE_DSA, OPENSSL_KEYTYPE_DH, OPENSSL_KEYTYPE_RSA or OPENSSL_KEYTYPE_EC

<?php
$keyPair = openssl_pkey_new(['private_key_bits' => 512, 'private_key_type' => OPENSSL_KEYTYPE_RSA]);
openssl_pkey_export($keyPair, $privateKey);
$publicKey = openssl_pkey_get_details($keyPair)['key'];
@poulou0
poulou0 / minicom-gsm.txt
Last active October 9, 2022 09:41
minicom for GSM/GPRS/GNSS/Bluetooth HAT for raspberry pi
SIM800L Troubleshooting guide
https://youtu.be/qI8vdiQdXtA
Raspberry Pi - Using a GPRS Modem for Network
https://youtu.be/T2NBpfgfPaI
minicom -D /dev/ttyUSB0 -b 115200
on windows - setup a new connection or network
//no username or password
@poulou0
poulou0 / README.md
Last active September 23, 2022 07:37
Predict tensorflow handposes with Node.js, capturing pictures from mjpg-streamer url
@poulou0
poulou0 / README.md
Last active September 23, 2022 07:35
Node.js `pigpio` + two servos

Node.js (pigpio) + two servos

Requirements

  • sudo npm install -g pigpio

Use

cd ~ && \
git clone https://gist.github.com/poulou0/a20c61d41f6f5b787caab4bd10cdf13b pigpio-servos && \
cd pigpio-servos &amp;&amp; \
@poulou0
poulou0 / README.md
Last active September 23, 2022 07:18
mjpg-streamer notes

mjpg-streamer

Install

sudo apt-get install cmake libjpeg62-turbo-dev gcc g++ && \
cd ~ && \
git clone https://github.com/jacksonliam/mjpg-streamer && \
cd mjpg-streamer/mjpg-streamer-experimental/ && \
make && sudo make install && \
printf '[Unit]\nDescription=Start mjpeg-streamer on startup.\nAfter=multi-user.target\n\n[Service]\nType=simple\nExecStart=/usr/local/bin/mjpg_streamer -o "output_http.so -w ./www" -i "input_uvc.so"\nExecStop=/usr/bin/killall mjpg_streamer\n\n[Install]\nWantedBy=multi-user.target\n' | sudo tee /etc/systemd/system/mjpeg-streamer.service && \
sudo systemctl enable mjpeg-streamer.service && sudo systemctl start mjpeg-streamer.service
@poulou0
poulou0 / JavascriptClient.html
Last active July 11, 2022 07:11
Dead simple PHP Websocket with Ratchet
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
var conn = new WebSocket('ws://localhost:8080/chat?apiToken=blahblah');
conn.onmessage = function(e) { console.log(e.data); };
conn.onopen = function(e) { conn.send('Hello Me!'); };
</script>
  • kernel install

    https://github.com/linux-surface/linux-surface/wiki/Installation-and-Setup
    
  • Firefox touchscreen scroll

    https://superuser.com/a/1485044
    
  • Pop!_OS bluetooth not working after installing linux-surface/linux-surface

@poulou0
poulou0 / linux-cheatsheet.md
Last active April 23, 2023 14:15
linux cheatsheet
  • nmap

    If installed with snap it gives an error: dnet: Failed to open device enp0sxxxx

    Fix: https://askubuntu.com/a/1312647

    scan network
    sudo nmap -sT -O 192.168.1.0/24 > nmap_output
    
@poulou0
poulou0 / Xorg-headless-raspberry-pi.md
Last active March 3, 2023 12:45
Run x server (xorg xinit) on a headless raspberry pi in DISPLAY=:0

Install the minimum

sudo apt update && \
sudo apt install xvfb x11vnc xinit tightvncserver && \

We start Xorg server through Xvfb

printf "[Unit]\nDescription=xvfb custom\nAfter=multi-user.target\nStartLimitIntervalSec=0\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nUser=pi\nExecStart=/usr/bin/xinit -- /usr/bin/Xvfb :0 -screen 0 1360x768x24\n\n[Install]\nWantedBy=multi-user.target\n" | sudo tee /etc/systemd/system/xvfb.service && \
sudo systemctl enable xvfb.service && sudo systemctl start xvfb.service \

We need to put something in the .initrc

Example

sudo apt install openbox tint2 firefox && printf "firefox -width 1360 -height 768 &\ntint2 &\nopenbox" > ~/.xinitrc

@poulou0
poulou0 / raspi-cheat-sheet.md
Last active October 21, 2022 13:34
raspi4 cheat sheet

To ssh without password

ssh-copy-id pi@192.168.x.x

Restart if offline

Append a job to crontab https://stackoverflow.com/a/16068840/1748645

(crontab -l; echo "*/5 * * * * /bin/bash -c \"ping -c 1 8.8.8.8 &> /dev/null || sudo reboot\"") | crontab