Skip to content

Instantly share code, notes, and snippets.

View micheleb's full-sized avatar

Michele Bonazza micheleb

  • Free as in lancer, formerly justwatch.com, sketchtogether.com, urbi.co
  • Berlin
View GitHub Profile
@micheleb
micheleb / text-editor.html
Created November 16, 2019 10:08
Ligthweight text editor
data:text/html, <html><head><title>Michele Editor</title><style>body{font-size:24px;font-family:monospace;padding:1em;background-color:%23333;color:%23aaa;line-height:1.5;border:1px solid rgba(255,255,255,0.2);}div{width:100%25;min-height:1em;whitespace:pre-wrap;}div:focus{outline:0px solid transparent;}</style></head><body spellcheck=false><div contenteditable></div></body></html>
@micheleb
micheleb / keybindings.json
Created September 18, 2018 16:12
VSCode keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight"
},
@micheleb
micheleb / RandomIMEI.java
Last active January 14, 2021 16:29
Generate random IMEI numbers
import java.util.Random;
import static java.lang.Math.abs;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
public class RandomIMEI {
private static final Random GENERATOR = new Random();
private static final String[] IMEI_REPORTING_BODY_IDS = {"01", "10", "30", "33", "35", "44",
public class TimezoneChange {
private static final ZoneId ZONE = ZoneId.of("Europe/Madrid");
private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
.appendPattern("yyyy-MM-dd'T'HH:mm:ss")
.appendFraction(MILLI_OF_SECOND, 0, 3, true)
.toFormatter();
public static void main(String[] args) {
Instant converted = ZonedDateTime.of(LocalDateTime.parse(startDate, TIME_FORMATTER), ZONE).toInstant();
@micheleb
micheleb / vm_nmap
Last active February 8, 2020 09:28
A script to list all existing NAT forwarding rules in VirtualBox
#!/bin/bash
#
# vm_nmap
# Created on 2013/07/16 MB
#
# Lists all configured port forwarding rules for all VirtualBox VMs found
# in the caller user's home.
#
# If called from user root, lists all port forwarding rules for all VMs
# in all homes.
@micheleb
micheleb / vm_forward_delete
Created July 8, 2015 12:40
A script to delete NAT forwarding rules from a VirtualBox VM
#!/bin/bash
if [[ "$#" -eq "2" ]]; then
VBoxManage modifyvm "$1" --natpf1 delete "$2"
else
echo 'USAGE: vm_forward_delete vm_name rule_name'
fi
@micheleb
micheleb / vm_forward_add
Created July 8, 2015 12:38
A script to add NAT forwarding rules to a VirtualBox VM
#!/bin/bash
if [[ "$#" -eq "4" ]]; then
VBoxManage modifyvm "$1" --natpf1 "$2,tcp,,$3,,$4"
else
echo 'USAGE: vm_forward_add vm_name rule_name host_port guest_port'
fi
@micheleb
micheleb / redis_mass_delete.sh
Last active May 19, 2021 23:55
A simple script to delete a bunch of keys from redis all at once (not to be used in production instances!)
#!/bin/bash
#
# A simple script to delete a bunch of keys from redis all at once.
#
# Don't use it in production!!!1!1!one
read -p "redis port to connect to? [6379] " redis_port
if [[ "${redis_port}" == "" ]]; then
redis_port="6379"