Skip to content

Instantly share code, notes, and snippets.

@9names
9names / Cargo.toml
Created April 4, 2023 13:31
basic PAC blinky for ch32v003
[package]
name = "hello-wch"
version = "0.1.0"
edition = "2021"
[dependencies]
panic-halt = "0.2.0"
riscv-rt = "0.11.0"
embedded-hal = "0.2.7"
@xuechunL
xuechunL / cloudSettings
Last active February 12, 2020 02:31
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-12T02:30:43.197Z","extensionVersion":"v3.4.3"}
@lyda
lyda / metrics.lua
Last active September 21, 2022 04:16
Prometheus node-exporter in lua for openwrt
#!/usr/bin/lua
-- Metrics web server (0.1)
-- Copyright (c) 2015 Kevin Lyda
-- Apache 2.0 License
socket = require("socket")
netsubstat = {"IcmpMsg", "Icmp", "IpExt", "Ip", "TcpExt", "Tcp", "UdpLite", "Udp"}
cpu_mode = {"user", "nice", "system", "idle", "iowait", "irq",
"softirq", "steal", "guest", "guest_nice"}
netdevsubstat = {"receive_bytes", "receive_packets", "receive_errs",
@oskar456
oskar456 / bh1750.py
Created June 20, 2015 15:26
BH1750 python library
#!/usr/bin/python2
# vim: expandtab ts=4 sw=4
# Inspired by http://www.raspberrypi-spy.co.uk/2015/03/bh1750fvi-i2c-digital-light-intensity-sensor/
import smbus
import time
class BH1750():
""" Implement BH1750 communication. """
@codingtony
codingtony / buildHAProxy.sh
Last active March 8, 2019 10:48
Recipe to build HAProxy 1.7 using LibreSSL. Builds an almost static binary. See https://github.com/codingtony/docker-build-haproxy for how to use with a Docker Image
#!/bin/bash -e
DIR=$PWD/work
mkdir -p ${DIR}
rm -f ${DIR}/*.tar.gz
LIBRESSL=libressl-2.4.5
HAPROXY=haproxy-1.7.5
PCRE=pcre-8.39
@chriseidhof
chriseidhof / parsing.swift
Last active April 16, 2023 02:38
JSON Parsing in Swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As of Beta5, the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@hideaki-t
hideaki-t / unzip.py
Created May 18, 2014 07:34
unzipping a zip file with non-utf8 encoding by Python3
import zipfile
import sys
from pathlib import Path
def unzip(f, encoding, v):
with zipfile.ZipFile(f) as z:
for i in z.namelist():
n = Path(i.encode('cp437').decode(encoding))
if v:
@mcpherrinm
mcpherrinm / instructions.md
Last active October 25, 2015 02:35
Crosscompiling Rust to Arm

I want to write Rust code on my computer (x86_64, Ubuntu 14.04) and produce arm executables. I found hints on the internet, but not a concise set of instructions on what to do. So I wrote them down exactly:

apt-get install g++-arm-linux-gnueabihf
git clone https://github.com/mozilla/rust.git
mkdir rust/build-cross
cd rust/build-cross
../configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/local/rust-cross
make -j8 && make install
@tomjaguarpaw
tomjaguarpaw / lensesForArrows.lhs
Last active June 19, 2018 21:14
Lenses for Arrows describes how the Lens datatype from Control.Lens can be generalise to support arrows.
> {-# LANGUAGE Rank2Types #-}
>
> import Prelude hiding (id)
> import Data.Functor.Constant (Constant(Constant), getConstant)
> import Control.Arrow (Arrow, arr, first, Kleisli(Kleisli), runKleisli, (&&&))
> import Control.Category ((<<<))
> import Control.Lens (sequenceAOf)
> import qualified Control.Lens as L
> import qualified Control.Lens.Internal.Setter as LS
> import Data.Profunctor (Profunctor, rmap)
@leemars
leemars / sync.sh
Created July 5, 2012 02:50
Git -> SVN sync script
#!/bin/bash
if [[ $# != 1 && $# != 2 ]]
then
echo "$0 <path to git repository> [tree-ish]"
exit 1
fi
msg() {
echo -e -n "\e[32;1m==>\e[0m "