Skip to content

Instantly share code, notes, and snippets.

@dlech
dlech / gist:3856248
Created October 9, 2012 02:34
From Mozilla Thunderbird source code
/// This imap folder cannot have children :-(
const nsMsgFolderFlagType ImapNoinferiors = 0x04000000;
@dlech
dlech / htway.py
Last active October 11, 2022 15:26
ev3dev HTWay
#!/usr/bin/env python
# Python port of the HiTechnic HTWay for ev3dev
# Copyright (c) 2014-2015 G33kDude, David Lechner
# HiTechnic HTWay is Copyright (c) 2010 HiTechnic
import itertools
import os
import struct
import smbus
import time
for bus in range(3, 7):
try:
i2c = smbus.SMBus(bus)
print "Input port %d:" % (bus - 2)
for addr in range(0x01, 0x80, 2):
try:
for offset in range(0, 24, 8):
[Unit]
Description=Make bluetooth discoverable
After=legoev3-bluetooth.service
[Install]
WantedBy=legoev3-bluetooth.service
[Service]
Type=oneshot
ExecStart=/usr/sbin/hiconfig hci0 piscan
@dlech
dlech / pulseaudio-bluetooth.conf
Last active May 25, 2020 18:08
BlueZ 5 and PulseAudio on Debian jessie
<busconfig>
<policy user="pulse">
<allow send_destination="org.bluez"/>
</policy>
</busconfig>
#!/usr/bin/env python
import smbus
import time
for bus in range(3, 7):
curport = (bus - 2)
print "bus: %2d port: %2d " % (bus, curport)
try:
i2c = smbus.SMBus(bus)
@dlech
dlech / led-color-demo.py
Last active November 13, 2016 02:27
ev3dev LED color demo
#!/usr/bin/env python
import time
LED_PATH = "/sys/class/leds/ev3:%(color)s:%(direction)s/brightness"
def do_up_down(f1, f2, f3, f4):
for i in range(0, 256):
val1 = str(i)
val2 = str(255-i)
@dlech
dlech / rmmods.sh
Last active August 29, 2015 14:07
Helper for ev3dev driver development
#!/bin/bash
export p=/sys/class/lego-port/port
export s=/sys/class/lego-sensor/sensor
export tm=/sys/class/tacho-motor/motor
export dc=/sys/class/dc-motor/motor
export sv=/sys/class/servo-motor/motor
rmmods () {
modprobe -r wedo
@dlech
dlech / sysfs_notify_monitor.c
Last active August 29, 2015 14:17
motor poll example from @rhempel
/* ------------------------------------------------------------------------------
* This sample is based on code from:
*
* http://stackoverflow.com/questions/16367623/using-the-linux-sysfs-notify-call
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@dlech
dlech / runvt.sh
Last active August 29, 2015 14:21
ev3dev run on vt
#!/bin/bash
# This script is used to start a program from a remote terminal but have it run
# on a virtual terminal. openvt has to be run as root, so we use sudo for that.
# Then, we use sudo --user to run the actual program as the current user. We also
# wrap the invocation in a shell so that we can rediect stdout/stderr to the
# current terminal. Finally, we capture the stderr of openvt and parse it to get
# the tty that the program is being run on so that we can kill it later.
tmpfile=$(tempfile)