Skip to content

Instantly share code, notes, and snippets.

View gianpaolof's full-sized avatar
🏍️

gianpaolo gianpaolof

🏍️
  • Italy
View GitHub Profile
@gianpaolof
gianpaolof / setup-zeromq.sh
Created September 13, 2019 11:27 — forked from katopz/setup-zeromq.sh
Setup zeromq in Ubuntu 16.04
#!/usr/bin/bash
# Download zeromq
# Ref http://zeromq.org/intro:get-the-software
wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz
# Unpack tarball package
tar xvzf zeromq-4.2.2.tar.gz
# Install dependency
@gianpaolof
gianpaolof / docker-clear.bat
Created October 2, 2019 08:03 — forked from daredude/docker-clear.bat
delete all docker container and images on windows
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm -f %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi -f %%i
@gianpaolof
gianpaolof / .docker_aliases
Last active March 19, 2021 15:14 — forked from cjus/.docker_aliases
Docker aliases
#!/bin/sh
alias dm='docker-machine'
alias dmx='docker-machine ssh'
alias dk='docker'
alias dki='docker images'
alias dks='docker service'
alias dkrm='docker rm'
alias dkl='docker logs'
alias dklf='docker logs -f'
@gianpaolof
gianpaolof / docker_kill.sh
Created October 30, 2019 12:22 — forked from evanscottgray/docker_kill.sh
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
@gianpaolof
gianpaolof / commit_everything.sh
Last active May 27, 2020 10:02 — forked from robballou/commit_everything.sh
A script to commit the git parent repo and any submodule changes too
#!/bin/bash
#
# Usage: ./commit_everything.sh "Commit message"
BOLD=$(tput bold)
BLACK=$(tput setaf 0)
WHITE=$(tput setaf 7)
BLUE=$(tput setaf 4)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
@gianpaolof
gianpaolof / redirectExample.go
Created April 2, 2020 11:38 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@gianpaolof
gianpaolof / detect_evil_merge.sh
Created May 7, 2020 09:58 — forked from smileyborg/detect_evil_merge.sh
Two scripts that can be used to detect evil merges in Git. See http://stackoverflow.com/questions/27683077
#!/bin/bash
# A shell script to provide a meaningful diff output for a merge commit that can be used to determine whether the merge was evil.
# The script should be run from outside the git repository, with two arguments:
# 1 - the directory of the git repository
# 2 - the SHA for the merge commit to inspect
# The script will output one file:
# - the merge redone fresh without any conflicts resolved, diff'ed to the actual merge
output_file="diff.txt"
@gianpaolof
gianpaolof / update-repo.sh
Last active May 7, 2020 10:06 — forked from lalitkale/update-repo.sh
Update Local Repository Folders Recursively
#!/bin/bash
# Usage:
# ./update_git_repos.sh [parent_directory]
# example usage:
# ./update_git_repos.sh C:/GitProjects/ [MAKE SURE YOU USE / SLASHES]
updateRepo() {
local dir="$1"
local original_dir="$2"
cd $dir # switch to the git repo
@gianpaolof
gianpaolof / json_parser.c
Created October 14, 2020 12:38 — forked from alan-mushi/json_parser.c
Examples for the json-c tutorial.
/*
* A simple example of json string parsing with json-c.
*
* clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c
*/
#include <json.h>
#include <stdio.h>
int main() {
struct json_object *jobj;
@gianpaolof
gianpaolof / ConnectivityAndInternetAccess.kt
Created April 1, 2022 09:21
Class to check the Connectivity and Internet Access of an Android device.
/*
* Copyright (c) 2014 str4d
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: