Skip to content

Instantly share code, notes, and snippets.

View EdoardoVignati's full-sized avatar

Edoardo Vignati EdoardoVignati

View GitHub Profile
@EdoardoVignati
EdoardoVignati / track.sh
Created May 7, 2024 22:22
Track all the Git branches of all repositories
for folder in $(ls -d */); do
cd $folder
echo
echo ===========================
echo $folder
echo ===========================
for branch in $(git branch -r | grep -v HEAD | cut -d / -f 2,3,4,5); do
echo
echo "=>" $branch
@EdoardoVignati
EdoardoVignati / set-super-user.sql
Created November 8, 2023 22:05
Update SQL to enable Super User
UPDATE mysql.user SET Super_Priv='Y' WHERE user='<myuser>' AND host='localhost';
@EdoardoVignati
EdoardoVignati / git_wizard.bat
Last active July 6, 2023 08:18
Git Wizard 🧙‍♂️ - Git bulk operations manager (Windows only)
:: Prerequisite: git
:: Usage: Download the wizard
:: Create a file named "repos.txt" in the same folder of the wizard
:: Insert in the file the absolute path of the repositories to track, one per line
:: Double click on the wizard and follow the instructions
:: Contribution: Feel free to contribute to this script!
:: Credits: Edoardo Vignati <edoardo.vignati@akkodis.com>
:: Emanuele De Filippis <emanuele.defilippis@akkodis.com>
@EdoardoVignati
EdoardoVignati / material_button_with_border.dart
Last active June 17, 2022 13:23
Flutter MaterialButton with borders and optional rounded angles
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
side: const BorderSide(color: Colors.black),
),
elevation: 0,
onPressed: () {
//Do something
},
child: Text("Button text"),
@EdoardoVignati
EdoardoVignati / js-openlayers-intercept-click.js
Last active April 26, 2022 21:55
JS OpenLayers intercept click on marker and get coordinates with button cursor.
map.on("singleclick", function(e) {
feature = map.forEachFeatureAtPixel(e.pixel, function(feature) {
return feature;
});
var coord = feature.getGeometry().getCoordinates();
coord = ol.proj.transform(coord,"EPSG:3857","EPSG:4326");
console.log(coord);
});
map.on("pointermove", function (evt) {
@EdoardoVignati
EdoardoVignati / vector_reference_prototype.txt
Last active April 15, 2022 16:00
Header and prototype for function taking a reference to vector as argument in c++
==== my_main.cpp ====
#include <iostream>
#include "my_vector.hpp"
using namespace std;
int main()
{
vector<int> myvec = {1, 2, 3};
add_to_vector(myvec, 4);
for(int elem : myvec){
cout << elem << endl;
@EdoardoVignati
EdoardoVignati / bool-list-to-int-and-vice-versa.py
Created October 20, 2021 21:24
Convert bool list to int and vice versa
def convert_bool_array_to_int(bool_array):
to_str_array = [str(int(x)) for x in bool_array]
return int("".join(to_str_array), 2)
def convert_int_to_bool(int_value):
to_byte_string = "{0:b}".format(int(int_value)).rjust(5, "0")
return [x == "1" for x in to_byte_string]
@EdoardoVignati
EdoardoVignati / find-facebook-page-id.py
Last active June 26, 2022 12:29
Find ID of a Facebook page
#!/usr/bin/env python
# Updated in june 2022
import sys
import requests
import re
if len(sys.argv) != 2 or sys.argv[1] == "":
print("Provide a valid Facebook url page such as \"https://www.facebook.com/acme\"")
exit()
try:
@EdoardoVignati
EdoardoVignati / flask_multipart_form_file_upload.py
Created July 8, 2021 09:57
Read multipart form data from Flask
from werkzeug.utils import secure_filename
from flask import Flask, render_template, request
@app.route("/my-upload-endpoint", methods=["POST"])
def my_upload_function():
if request.files.get("my-file-field-name") is None:
return render_template("my_error_page.html", an_optional_message="Error uploading file")
# Put here some other checks (security, file length etc...)
f = request.files["my-file-field-name"]
f.save(secure_filename(f.filename))
@EdoardoVignati
EdoardoVignati / Find _disk_usage_in_bytes_and_filter.sh
Created March 20, 2021 17:20
Find disk usage in bytes and filter
find . -type f -exec du -b {} + | grep something.txt