Skip to content

Instantly share code, notes, and snippets.

@igricart
igricart / syslog.cpp
Created July 29, 2020 14:46
Script to handle interruption signal in c++ while also closing a log (Although it is unnecessary)
#include <iostream>
#include <syslog.h>
#include <string>
#include <csignal>
void signal_handler(int signal_num)
{
std::cout << "The interrupt signal is (" << signal_num << "). \n";
// terminate program
@igricart
igricart / udevadm
Created August 3, 2020 11:10
Get parameters from /dev/X
udevadm info --attribute-walk /dev/ttyUSB0
@igricart
igricart / tmux_pane
Last active August 4, 2020 11:26
Startup tmux with panes splitted
tmux new-session \; split-window -v -p 50 \; split-window -h -p 50 \; select-pane -t 0 \; split-window -h -p 50 \;
@igricart
igricart / get_output
Created August 5, 2020 10:38
Get std::cout from process in background
# <PID number> = 1234
strace -p<PID number> -s9999 -e write
@igricart
igricart / lte_interface
Created August 6, 2020 07:19
Add or remove lte connection
# Bring LTE connection up
ifconfig wwan0 up
# Bring LTE connection down
ifconfig wwan0 down
@igricart
igricart / time_to_file.cpp
Created August 9, 2020 09:46
Write time to a .txt file
#include <iomanip>
#include <chrono>
#include <ctime>
#include <iostream>
#include <string>
#include <fstream>
int main ()
{
auto now = std::chrono::system_clock::now();
@igricart
igricart / multithread.cpp
Created August 12, 2020 18:06
Multithreading
#include <assert.h>
#include <thread>
#include <mutex>
#include <future>
#include <iostream>
#include <deque>
int a = 0;
std::mutex mutex;
@igricart
igricart / 50-something.rules
Created August 26, 2020 12:12
Get device information for udev rules
# Put inside /etc/udev/rules.d/
udevadm info --attribute-walk /dev/video0
@igricart
igricart / chrono_test.cpp
Created September 9, 2020 08:09
Code to check time information from system with different units
#include <iostream>
#include <chrono>
#include <unistd.h>
using namespace std;
// main function to measure elapsed time of a C++ program
// using chrono library
int main()
{
auto start = chrono::steady_clock::now();
// do some stuff here
@igricart
igricart / ping.sh
Created September 9, 2020 08:16
Ping with timer information
#!/bin/bash
ping www.google.fr | while read pong; do echo "$(date +%F%T): $pong"; done
# This command would show the output in /tmp/ping.log | To check the values during runtime one could run `tail -f /tmp/ping.log`
ping www.google.fr | while read pong; do echo "$(date +%F%T): $pong"; done > /tmp/ping.log