Skip to content

Instantly share code, notes, and snippets.

View manchoz's full-sized avatar

Giampaolo Mancini manchoz

View GitHub Profile
@manchoz
manchoz / latlng.sh
Created May 18, 2012 15:18
Address geocoding in Bash with Google Maps API
#!/bin/bash
# Quick and dirty geocoding with Google Maps API
MAPSAPIURL="http://maps.googleapis.com/maps/api/geocode/json"
[ -f latlng.txt ] && rm latlng.txt
[ -f results.json ] && rm results.json
while read line; do
# Get address from column 3 and 4 of a CSV file provided as argument and prepare the string address. YMMV.
@manchoz
manchoz / latency.txt
Created May 31, 2012 14:39 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns

Keybase proof

I hereby claim:

  • I am manchoz on github.
  • I am manchoz (https://keybase.io/manchoz) on keybase.
  • I have a public key whose fingerprint is 2EE0 B45A ADBF 6CE3 FE16 3F06 1639 CD86 C111 7ECC

To claim this, I am signing this object:

## Modified commands
alias diff='colordiff' # requires colordiff package
alias grep='grep --color=auto'
alias more='less'
alias df='df -h'
alias du='du -c -h'
alias mkdir='mkdir -p -v'
alias nano='nano -w'
alias ping='ping -c 5'
@manchoz
manchoz / alpine-armhf.conf
Created March 3, 2016 14:07
Schroot Alpine ARM configuration
[alpine-armhf]
description=GNU/Linux ALpine
# Impostare la directory corretta
directory=/home/mancho/Chroot/rootfs-alpine-armhf
# Impostare gli utentiu corretti
users=mancho
root-groups=root
# Comando docker per lanciare container per ARM su GNU/Linux x86_64
# Prerequisiti: qemu-user-static + binfmt_support
$ docker run --rm -ti -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static container4armhf/armhf-alpine /bin/sh
$ docker run --rm -ti -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static resin/rpi-raspbian /bin/bash
# Per usare docker da utente (senza sudo/su)
$ sudo usermod -aG docker $(whoami)
$ newgrp docker
# Lista dei formati binari supportati da binfmt_misc
FROM container4armhf/armhf-alpine
COPY qemu-arm-static /usr/bin/
RUN apk --update add python3
RUN rm /usr/bin/qemu-arm-static
CMD ["/bin/sh"]
from mcpi.minecraft import Minecraft
from gpiozero import DigitalInputDevice
from time import sleep
mc = Minecraft.create()
mc.postToChat("Micromine bitcraft")
pin0 = DigitalInputDevice(17)
while True:
@manchoz
manchoz / bitfields_struct.cpp
Created November 15, 2017 10:22
Use ctypes and some python magic to unpack C/C++ bitfields struct dynamically.
typedef struct __attribute__ ((packed)) Data {
uint32_t temperature_internal: 10;
uint32_t temperature: 10;
uint32_t pressure: 12;
uint32_t humidity: 10;
uint32_t temperature_soil: 10;
uint32_t battery_level: 7;
uint32_t leaf_wetness: 4;
uint32_t pad0: 1;
/*
Basic ESP8266 MQTT example
This sketch demonstrates the capabilities of the pubsub library in combination
with the ESP8266 board/library.
It connects to an MQTT server then:
- publishes "hello world" to the topic "outTopic" every two seconds
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary