This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GetExternalIP() (string, error) { | |
ifaces, err := net.Interfaces() | |
if err != nil { | |
return "", err | |
} | |
for _, iface := range ifaces { | |
if iface.Flags&net.FlagUp == 0 { | |
continue // interface down | |
} | |
if iface.Flags&net.FlagLoopback != 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((clojure-mode . ((cider-preferred-build-tool . clojure-cli) | |
;; you can specify multiple profiles to use | |
(cider-clojure-cli-global-options . "-M:dev:local:reloaded:inspect/reveal-nrepl-cider") | |
(cider-jack-in-dependencies . nil) | |
(cider-jack-in-nrepl-middlewares . nil) | |
(cider-jack-in-lein-plugins . nil) | |
(cider-clojure-cli-parameters . "")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connections: | |
# LED-K : GND | |
# LED-A : GPIO2 | |
# RESET : GPIO25 | |
# DCX : GPIO24 | |
# SDA : GPIO10 | |
# SCL : GPIO11 | |
# VDDI : 3.3V | |
# VDD : 3.3V | |
# CS : GPIO8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send UDP broadcast and read reply | |
# Edited from | |
# https://gist.github.com/ninedraft/7c47282f8b53ac015c1e326fffb664b5 | |
import socket | |
import time | |
import binascii | |
import _thread as thread | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shallow clone all repos from bitbucket. | |
# Usage: | |
# python3 bitbucket.py -u [USERNAME] -p [BITbucket_APP_TOKEN] -o [OUTPUT_DIR] | |
# Requirements: | |
# 1. Setup app password in Bitbucket | |
# 2. Setup local ssh keys | |
# 3. Only git repositories are supported | |
from requests.auth import HTTPBasicAuth | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Clone all repos from github. | |
# Usage: | |
# python3 github.py -t [GITHUB_TOKEN] -o [OUTPUT_DIR] -k [PROJECT_OWNER] | |
from requests.auth import HTTPBasicAuth | |
import requests | |
import os | |
repos = set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import evdev | |
import subprocess | |
from evdev import InputDevice, categorize | |
# To find the path, use `evtest` | |
dev = InputDevice('/dev/input/event2') | |
def ignore_error(func): | |
def myfunc(*args, **kwargs): | |
try: | |
func(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ignore_error(func): | |
def myfunc(*args, **kwargs): | |
try: | |
func(*args, **kwargs) | |
except Exception: | |
print('Error ignored') | |
traceback.print_exc(file=sys.stdout) | |
return myfunc | |
@ignore_error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FS005009 Formaldehyde (HCHO) sensor | |
# 0 1 2 3 4 5 6 7 8 | |
# 起始位 设备类型 单位 小数位数 气体浓度高位 气体浓度低位 满量程高位 满量程低位 校验值 | |
# ff 17 04 00 00 1b 07 d0 f3 | |
# | |
# 气体浓度值=气体浓度高位*256+气体浓度低位, 单位:mg/m3 | |
# Sample output: | |
# ff 17 04 00 00 1b 07 d0 f3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get event id and names for connected HID devices: | |
# cat /proc/bus/input/devices | grep -P '^[NH]: ' | paste - - | |
# | |
# To allow current user to run this script without root: | |
# sudo usermod -a -G input $USER | |
import evdev | |
from evdev import InputDevice, categorize # import * is evil :) | |
import time | |
import traceback | |
import sys |