Skip to content

Instantly share code, notes, and snippets.

@hegge
hegge / gist:5133826
Created March 11, 2013 12:10
Corda Daccord lsusb -v
Bus 002 Device 009: ID 0d8c:0309 C-Media Electronics, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x0d8c C-Media Electronics, Inc.
@hegge
hegge / avg_cyclic()
Created July 15, 2010 13:44
Mean of circular quantities in SQL
-- MySQL
SELECT UNIX_TIMESTAMP(date), avg_cyclic, frequency_start , frequency_stop, intensity, source
FROM (SELECT MAX(id) AS max_id, CONCAT(echo.frequency_start , '-', echo.frequency_stop) AS frequency
FROM echo
WHERE channel = {0}
GROUP BY frequency) AS id,
echo,
(SELECT
IF (avg(sin(direction*PI()/180))>0 AND avg(cos(direction*PI()/180))>0,
atan(avg(sin(direction*PI()/180))/avg(cos(direction*PI()/180))),
all: program run plot
.PHONY: run plot
program: file.c
gcc -o program file.c
run:
./program
#!/usr/bin/perl
use strict;
use warnings;
# Use: cat file | ./filter.pl > new_file
while(<>) {
if (/^(\w+(\\\w+)*)\\(\w+)\t(\w+)$/) {
print "$1;$3;$4\n";
}
/* Read acc and gyro */
body_linear_acc /* contains: u_dot, v_dot, w_dot */
body_rotation_acc /* contains: p_dot, q_dot, r_dot */
/* Calculate angle TODO: compensate for turning */
local_angle = find_angles_atan2(body_linear_acc)
/* Read GPS position and speed */
gps_speed /*contains x, y, z */
gps_position /* contains x_dot, y_dot, z_dot */
@hegge
hegge / gist:70204bead964de3985dc
Last active August 29, 2015 14:19
Mutt LDAP DavMail lookup
#!/usr/bin/perl
# Based on http://www.perlmonks.org/?node_id=65152
use strict;
use Net::INET6Glue::INET_is_INET6;
use Net::LDAP;
use constant HOST => 'ip6-localhost:1389';
use constant BASE => 'ou=people';
@hegge
hegge / gist:9663373
Last active August 29, 2015 13:57 — forked from anonymous/gist:9663368
$ git --version
git version 1.8.5.rc2.7.g8167612 # same behavour with 1.9.1.423.g4596e3a
$ git init
Initialized empty Git repository in /home/torstein/tmp/git-empty/.git/
$ echo "f" >file
$ git add file