Skip to content

Instantly share code, notes, and snippets.

@madagaga
madagaga / gist:cab1e6c03d0efd76a468c103ac9ddc5f
Last active April 20, 2020 07:28
hcidump packet analysis for mijia BT
$hcidump --raw
> 04 3E 25 02 01 00 00 7C C2 DB A8 65 4C 19 02 01 06 15 16 95
FE 50 20 AA 01 09 7C C2 DB A8 65 4C 0D 10 04 D5 00 28 02 AB
7C C2 DB A8 65 4C => mac address
Packet size vary from 37 to 41
when 41 temp and humidity are set on the 2 last bytes before CRC
28 02 => Humidity => big endian reverse 0228 => to int => 552 => 55.2%
@thomasfr
thomasfr / iptables.sh
Last active October 17, 2024 07:55
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
@waynemoore
waynemoore / month_day_range.py
Created July 27, 2011 11:01
Get first and last day of a particular month using python-dateutil.
import datetime
# requires python-dateutil (http://labix.org/python-dateutil)
from dateutil.relativedelta import relativedelta
def get_month_day_range(date):
"""
For a date 'date' returns the start and end date for the month of 'date'.
Month with 31 days: