Skip to content

Instantly share code, notes, and snippets.

View guilhermebene's full-sized avatar

Guilherme Beneti Martins guilhermebene

View GitHub Profile
$remoteport = bash.exe -c "ip addr show eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@dhrrgn
dhrrgn / formatters.py
Last active April 6, 2022 19:51
Python timedelta object formatting for humans.
def human_delta(tdelta):
"""
Takes a timedelta object and formats it for humans.
Usage:
# 149 day(s) 8 hr(s) 36 min 19 sec
print human_delta(datetime(2014, 3, 30) - datetime.now())
Example Results:
23 sec
@tfeldmann
tfeldmann / i2c_scanner.ino
Created April 18, 2013 09:13
A I2C Scanner for Arduino
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not known.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
@schlamar
schlamar / processify.py
Last active April 17, 2024 19:19
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value
@beniwohli
beniwohli / greek_alphabet.py
Created January 4, 2011 19:29
A Python dictionary mapping the Unicode codes of the greek alphabet to their names
greek_alphabet = {
u'\u0391': 'Alpha',
u'\u0392': 'Beta',
u'\u0393': 'Gamma',
u'\u0394': 'Delta',
u'\u0395': 'Epsilon',
u'\u0396': 'Zeta',
u'\u0397': 'Eta',
u'\u0398': 'Theta',
u'\u0399': 'Iota',