Skip to content

Instantly share code, notes, and snippets.

View miticojo's full-sized avatar

Giorgio Crivellari miticojo

View GitHub Profile
@eruffaldi
eruffaldi / gettoken.sh
Created September 25, 2018 09:23
Google OAuth 2.0 full example bash script.
#!/bin/bash
#1) on https://console.developers.google.com/ register project and associate API from library
# OUTPUT: client_id,client_secret
client_id="..."
client_secret="...."
#2) get authorization code at the following link using web browser
# OUTPUT: code
scope="https://www.googleapis.com/auth/drive"
@miticojo
miticojo / vagrant-setup.ps1
Last active April 4, 2017 07:33
Vagrant setup for Linux CentOS/Fedora/Debian/Ubuntu, OSX and Windows
$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Start-Transcript -path $scriptPath\Win10_Ansible_Development_PC_Install.log -append
# elevate privileges to administrator to install chocolatey and other needed packages
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
@jlsherrill
jlsherrill / task_delete.md
Last active April 22, 2021 17:37
Delete a task

replace the ID with the task ID from Monitor > Tasks (not from the dynflow console)

For Katello 3.0 & Satellite 6.2:

foreman-rake foreman_tasks:cleanup FILTER='id=1cc6495d-f7ee-4011-9659-ea24ae9240f0' STATES=paused,stopped VERBOSE=true
@DeanCording
DeanCording / README.md
Last active December 4, 2021 07:31
ESP8266 OTA Firmware Upgrade Manager

This flow provides a tool for managing Over The Air firmware updates for ESP8266 Wifi SoC modules running the Arduino ESP8266 environment. It also supports Sonoff devices running the Tasmota firmware.

The ESP8266 is a very small, cheap, and reasonably powerful microcontroller with integrated WiFi. The OTA firmware upgrade process allows you to install these modules in location and have them automatically upgrade their firmware over WiFi.

The OTA upgrade library contacts a specified URL and passes the name and MD5 hash of the module's current firmware. This server implemented in this flow will compare the supplied MD5 hash against the one for the latest firmware and, if different, send the new firmware to the module. The server will uses either the module's MAC address or firmware name to identify the correct firmware file to send. The firmware can be specified in either the request URL or in the x-esp8266-version property in the

@DeanCording
DeanCording / Template_ESP8266.ino
Last active April 29, 2023 03:23
ESP8266 Arduino project template with optional OTA firmware update
/**
* ESP8266 project template with optional:
* - WiFi config portal - auto or manual trigger
* - OTA update - Arduino or web server
* - Deep sleep
* - Process timeout watchdog
*
* Copyright (c) 2016 Dean Cording <dean@cording.id.au>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@dpino
dpino / ns-inet.sh
Last active June 19, 2024 11:31
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@leommoore
leommoore / mongodb_3.2.x_replica_sets_on_aws_ec2.md
Last active March 15, 2022 22:28
MongoDB 3.2.x Replica Sets on AWS EC2

#MongoDB 3.2.x Replica Sets on AWS EC2 A MongoDB replica set provides a mechanism to allow for a reliable database services. The basic replica set consists of three servers, a primary, a secondary and an arbitrator. The primary and secondary both hold a copy of the data. The arbitrator is normally a low spec server which just monitors the other servers and help with the failover process. In production, there can be more than three servers.

To setup mongo as a replica set on Amazon Web Services EC2 you need to first setup a security group with ssh on port 22 and mongodb on port 27017. You then need to create three servers. Select Ubuntu 14.04 LTS x64 and a micro (or bigger depending on your database size, ideally you should have enough memory to match your database size) instance for the primary and secondary and a nano instance for the arbitrator.

##Adjust the File System on each Server The operating system by default will update the last access time on a file. In a high data throughput database application

@hattmarris
hattmarris / mysql.sql
Created December 22, 2015 21:59
MySQL
# tabular view of data with scrolling
mysql> pager less -SFX
mysql> SELECT * FROM sometable;
@oldo
oldo / video-metada-finder.py
Last active March 2, 2023 22:33
A python function utilising `ffprobe` to find any metadata related to a video file. Examples of what it can find include bitrate, fps, codec details, duration and many more. This gist returns the video height and width as an example.
#!/usr/local/bin/python3
import subprocess
import shlex
import json
# function to find the resolution of the input video file
def findVideoMetada(pathToInputVideo):
cmd = "ffprobe -v quiet -print_format json -show_streams"
args = shlex.split(cmd)
args.append(pathToInputVideo)
@juliedavila
juliedavila / sample_module.py
Last active November 30, 2017 13:05
New Ansible Module Boilerplate
#!/usr/bin/python
# libraries you import here, must be present on the target node.
import os
# You can defined other functions up here to make your code more modular.
# These functions will need to be called from main(), either directly or through N number of other functions
# that eventually lead back to main()
def main():