Skip to content

Instantly share code, notes, and snippets.

@igricart
igricart / oneshot_example.md
Last active October 28, 2020 10:27
Gist to create some test files to show the basic functionality of a oneshot systemd service

Test script

create a script file:

touch /tmp/oneshot_example

copy and paste the content from Run script session then run chmod +x /tmp/oneshot_example and sudo /tmp/oneshot_example

Raw example can be found here

Run script

@igricart
igricart / FindGMock.cmake
Created October 22, 2020 12:16
enable find_package(GMock) on cmakelists
# Locate the Google C++ Mocking Framework.
# (This file is almost an identical copy of the original FindGTest.cmake file,
# feel free to use it as it is or modify it for your own needs.)
#
#
# Defines the following variables:
#
# GMOCK_FOUND - Found the Google Testing framework
# GMOCK_INCLUDE_DIRS - Include directories
#
@igricart
igricart / set_docker.sh
Last active October 14, 2020 10:59
Install docker and set the system to no use it as sudo
#!/bin/bash
sudo apt update
sudo apt install docker.io
sudo usermod -aG docker ${USER}
su - ${USER}
id -nG
docker version
docker run hello-world
@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
@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 / 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 / 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 / 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 / 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 / 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