Skip to content

Instantly share code, notes, and snippets.

View stefanofiorentino's full-sized avatar

Stefano Fiorentino stefanofiorentino

View GitHub Profile
@stefanofiorentino
stefanofiorentino / subs_pragma_onces
Last active April 20, 2020 16:17
remove pragma onces at once
#!/bin/bash
# grep -rn "#pragma once" src/* | sed 's/:1:#pragma once//g' > file_list
for name in $(cat file_list);
do
echo $name;
cleaned=$(echo $name | sed 's/src\/uvw\///g' | sed 's/\.hpp//g' | sed 's/\.h//g')
echo $cleaned
upper=$(echo $cleaned | tr '[a-z]' '[A-Z]' | xargs -r -n1 -I {} echo UVW_{}_INCLUDE_H)
@stefanofiorentino
stefanofiorentino / main2.cpp
Created March 31, 2020 23:30
libuvw example use of async and thread [uvw is a libuv c++ wrapper]
#include <uvw.hpp>
#include <cassert>
#include <iostream>
#include <memory>
#include <chrono>
int main() {
using namespace std::chrono_literals;
// get the default loop
# - Find libmosquittopp
# Find the native libmosquittopp includes and libraries
#
# MOSQUITTOPP_INCLUDE_DIR - where to find mosquitto.h, etc.
# MOSQUITTOPP_LIBRARIES - List of libraries when using libmosquittopp.
# MOSQUITTOPP_FOUND - True if libmosquittopp found.
if (NOT MOSQUITTOPP_INCLUDE_DIR)
find_path(MOSQUITTOPP_INCLUDE_DIR mosquitto.h)
endif()
# - Find libjsoncpp
# Find the native libjsoncpp includes and libraries
#
# JSONCPP_INCLUDE_DIR - where to find json.h, etc.
# JSONCPP_LIBRARIES - List of libraries when using libjsoncpp.
# JSONCPP_FOUND - True if libjsoncpp found.
if (NOT JSONCPP_INCLUDE_DIR)
find_path(JSONCPP_INCLUDE_DIR json/value.h HINTS /usr/include/jsoncpp)
endif()
@stefanofiorentino
stefanofiorentino / git-amend
Created January 20, 2020 10:27
automatic git commit --amend with reset authors (and commit timestamp!!)
#!/bin/bash
git commit --amend --reset-author
@stefanofiorentino
stefanofiorentino / demo.sh
Created January 15, 2020 13:34
Laboratorio IoT @ Relewant SA - 15 gennaio 2020
# SHELL 1:
tmux
Ctrl+b \"
Ctrl+b o
# SHELL 1: clean docker env
docker ps -aq | xargs -r -n1 docker rm -f
docker images -aq | xargs -r -n1 docker rmi -f
clear
@stefanofiorentino
stefanofiorentino / gist:91ac92bd571d8d380fcd452922480ffd
Last active January 23, 2019 11:26
rename all cpp files to hpp extension
#!/bin/bash
find . -name "*.cpp" | grep "cpp$" | sed 's/cpp$//g' | xargs -r -n1 -I {} echo mv {}cpp {}hpp
find . -name "*.hpp" | xargs -r -n1 -I {} sed -i '1s;^;#pragma once\n;' {}
@stefanofiorentino
stefanofiorentino / libmicrohttpd.diff
Created December 11, 2017 14:31
diff to compile json-rpc-cpp on ubuntu 14.04
--- a/src/jsonrpccpp/server/connectors/httpserver.cpp
+++ b/src/jsonrpccpp/server/connectors/httpserver.cpp
@@ -43,22 +43,8 @@ IClientConnectionHandler *HttpServer::GetHandler(const std::string &url) {
bool HttpServer::StartListening() {
if (!this->running) {
- const bool has_epoll =
- (MHD_is_feature_supported(MHD_FEATURE_EPOLL) == MHD_YES);
- const bool has_poll =
- (MHD_is_feature_supported(MHD_FEATURE_POLL) == MHD_YES);
@stefanofiorentino
stefanofiorentino / gist:fd2982d2d42df9d55afe
Last active November 21, 2015 09:17 — forked from anonymous/gist:a57883a80e02b4bab701
How to get all iphone, ipad, windows phone and android icons from "App Icon Template 4.1"
#!/bin/bash
# clear terminal window
clear
# variabili per creare sotto cartelle iOS, Android e WP
export RET_PATH=$PWD
###### iOS
mkdir ./iOS