Skip to content

Instantly share code, notes, and snippets.

Danilo Bargen dbrgn

Block or report user

Report or block dbrgn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dbrgn
dbrgn / testserver.py
Created Apr 18, 2019
WASM aware python testserver
View testserver.py
from http import server
PORT = 8000
class WasmAwareRequestHandler(server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.extensions_map['.wasm'] = 'application/wasm'
View integrationtests.rs
extern crate hyper;
extern crate reqwest;
extern crate rustysafe;
use std::thread;
use hyper::Server;
use hyper::rt::Future;
use hyper::service::service_fn;
@dbrgn
dbrgn / button-shutdown.py
Created Jun 29, 2018
Example: Shutdown script for iC880A backplane
View button-shutdown.py
#!/usr/bin/env python3
import os
import sys
import time
import RPi.GPIO as g
print('Initializing...')
# Pins
@dbrgn
dbrgn / numbering_mode.md
Last active Mar 23, 2018
RPLCD numbering mode notes
View numbering_mode.md

In RPLCD version 1.0, some APIs were slightly changed. Previously the CharLCD instance would provide default values for the pin numbers and the numbering mode. But that was changed, since it may be dangerous if these pins are connected to other hardware.

So if you have installed version 1.0 of RPLCD, you need to provide the pin numbering mode yourself. If your code previously looked like this:

from RPLCD import CharLCD
lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[40, 38, 36, 32, 33, 31, 29, 23])

...and if you use the BOARD numbering scheme, then change the code like this:

@dbrgn
dbrgn / leds_button.py
Last active Apr 5, 2018
iC880A Backplane: LED and button example script
View leds_button.py
import sys
import time
from RPi import GPIO
LED_R = 36
LED_Y = 38
LED_B = 40
BUTTON = 32
# Use the BOARD numbering system
@dbrgn
dbrgn / adc.py
Last active Jun 2, 2017
iC880A Backplane: ADC example script
View adc.py
"""
Example script to read the input voltage, measured by the MCP3425 ADC.
Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/22072b.pdf
"""
# -*- coding: utf-8 -*-
from __future__ import print_function, division
import time
import smbus
@dbrgn
dbrgn / state.rs
Created Apr 3, 2017
Custom Text based Diesel type for an enum
View state.rs
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all="snake_case")]
pub enum State {
Pending,
Sending,
Sent,
Failed,
}
impl fmt::Display for State {
View gist:d729b144f7aaa80f246e40085ded37e9
$ docker run python:3.4 pip install pytest-pep8
Unable to find image 'python:3.4' locally
3.4: Pulling from library/python
693502eb7dfb: Pull complete
081cd4bfd521: Pull complete
5d2dc01312f3: Pull complete
54a5f7da9a4f: Pull complete
25b1aaa33436: Pull complete
3168f1c413f2: Pull complete
7834951bf6f6: Pull complete
View bindings.rs
/* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Rectangle {
pub width: ::std::os::raw::c_int,
pub height: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_Rectangle() {
View gist:8a214487ec80c4673e31c9226c6f832b
= note: /home/danilo/Projects/rad1o-rust/target/thumbv7em-none-eabihf/release/deps/gravitation-e8a3aecc3f3d7459.0.o: In function `ram':
gravitation.cgu-0.rs:(.text.ram+0x2ee): undefined reference to `__aeabi_ui2d'
gravitation.cgu-0.rs:(.text.ram+0x2fc): undefined reference to `__aeabi_ddiv'
gravitation.cgu-0.rs:(.text.ram+0x308): undefined reference to `__aeabi_dmul'
gravitation.cgu-0.rs:(.text.ram+0x312): undefined reference to `__aeabi_ui2d'
gravitation.cgu-0.rs:(.text.ram+0x31c): undefined reference to `__aeabi_ddiv'
gravitation.cgu-0.rs:(.text.ram+0x324): undefined reference to `__aeabi_dmul'
gravitation.cgu-0.rs:(.text.ram+0x35e): undefined reference to `__aeabi_ddiv'
gravitation.cgu-0.rs:(.text.ram+0x37e): undefined reference to `__aeabi_dsub'
gravitation.cgu-0.rs:(.text.ram+0x38a): undefined reference to `__aeabi_ddiv'
You can’t perform that action at this time.