Cheap usb rfid reader
This PN532 board has better read range than my first try, which was this RC-522 board. But, the PN532 possibly uses I2C clock stretching, which makes it fail sometimes on my Raspberry Pi 3B+. The flakiness sometimes takes hours to show up, and I couldn't find a software way to reset it short of a reboot.
What seems to work better is to make it a USB board with a CP2102 usb serial chip. Now I have [raspberry pi 3B+] -> [usb serial] -> [PN532 in UART mode]. The libnfc path for it is LIBNFC_DEFAULT_DEVICE=pn532_uart:/dev/ttyUSB0
.
Here's how to connect the boards right against each other:
Printing a temperature calibration tower for PETG with Slic3r 1.2.9
https://github.com/slic3r/Slic3r/wiki/Conditional-Gcode-Syntax-Spec doesn't work, but it will interpolate "[variable]" at least.
Go to https://www.thingiverse.com/thing:2729076, get SmartTemperatureTower_PETG_220-265.stl, Slic3r it to 0.2mm layers, and in Printer Settings -> Before layer change G-code, enter this:
; layer=265-5*int(([layer_z]-.35-1.4)/10)
Export G-code. Run this on the file:
perl -lpi -e '($n)=/layer=(.*)/; if ($n) { $_="M104 S".eval($n); }' SmartTemperatureTower_PETG_220-265.gcode
Print that.
Building julia on raspberry pi
I figured out how to bulid julialang from source on a raspberry pi 3 running raspian.
Add more swap, since the last build step needs about 1.3GB of ram:
# fallocate -l 1G swap2 # chmod 0600 swap2 # mkswap swap2 Setting up swapspace version 1, size = 1048572 KiB no label, UUID=60ae0fd6-deec-4148-ac93-b59df12cdb97 # swapon swap2 # free total used free shared buffers cached Mem: 948012 395968 552044 1112 45796 73888 -/+ buffers/cache: 276284 671728 Swap: 1150968 59188 1091780
Install dependencies:
aptitude install libunwind-dev gfortran m4 cmake libcurl4-openssl-dev libssl-dev libssh2-1-dev
Get julia and build:
$ git clone https://github.com/JuliaLang/julia.git $ cd julia ~/julia $ make
Run:
~/julia $ ./julia WARNING: unable to determine host cpu name. _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_) | Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.5.0-dev+3809 (2016-04-30 15:44 UTC) _/ |\__'_|_|_|\__'_| | Commit 7315f52 (0 days old master) |__/ | arm-linux-gnueabihf julia>
Fixing BCF2000 power supply
I have a BCF2000 midi controller which I got in 2007 and it started being flaky. The motors didn't run, and USB didn't register well. Here it is misspelling its own product name and otherwise failing to set up:
[1559654.831070] usb 1-1: config index 0 descriptor too short (expected 101, got 55) [1559654.831075] usb 1-1: config 1 has an invalid descriptor of length 0, skipping remainder of the config [1559654.831078] usb 1-1: config 1 has 0 interfaces, different from the descriptor's value: 2 [1559654.831656] usb 1-1: New USB device found, idVendor=1397, idProduct=00bc [1559654.831669] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1559654.831672] usb 1-1: Product: BCF200 [1559654.831674] usb 1-1: Manufacturer: BE一䜀䔀刀 [1559659.668903] usb 1-1: new full-speed USB device number 48 using xhci_hcd [1559659.797558] usb 1-1: config index 0 descriptor too short (expected 101, got 1) [1559659.797563] usb 1-1: invalid descriptor for config index 0: type = 0x0, length = 1 [1559659.797566] usb 1-1: can't read configurations, error -22 [1559659.908832] usb 1-1: new full-speed USB device number 49 using xhci_hcd [1559660.020929] usb 1-1: Device not responding to setup address. [1559660.241696] usb 1-1: config index 0 descriptor too short (expected 101, got 60) [1559660.241704] usb 1-1: config 1 interface 1 altsetting 0 has 0 endpoint descriptors, different from the interface descriptor's value: 2 [1559660.242579] usb 1-1: New USB device found, idVendor=1397, idProduct=00bc [1559660.242583] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1559660.242586] usb 1-1: Product: BCF00 [1559660.242588] usb 1-1: Manufacturer: BRINGER [1559661.955604] usb 1-1: USB disconnect, device number 49 [1559664.971591] usb 1-1: new full-speed USB device number 50 using xhci_hcd [1559665.100817] usb 1-1: config index 0 descriptor too short (expected 101, got 55) [1559665.100822] usb 1-1: config 1 has an invalid descriptor of length 1, skipping remainder of the config [1559665.100825] usb 1-1: config 1 has 1 interface, different from the descriptor's value: 2 [1559665.102234] usb 1-1: New USB device found, idVendor=1397, idProduct=00bc [1559665.102238] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1559665.102240] usb 1-1: Product: BCF2000 [1559665.102242] usb 1-1: Manufacturer: BEHRINGER [1559665.103580] usb 1-1: cannot find UAC_HEADER [1559665.103596] snd-usb-audio: probe of 1-1:1.0 failed with error -22
Upon seeing forum posts like this one I opened the case and saw that my filter caps had indeed burst a little.
I soldered in new ones (like Jameco part 1000 uF 16 Volt Radial Capacitor):
and now it works great:
[1568546.232394] usb 4-1.6: new full-speed USB device number 83 using ehci-pci [1568546.326265] usb 4-1.6: New USB device found, idVendor=1397, idProduct=00bc [1568546.326270] usb 4-1.6: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [1568546.326273] usb 4-1.6: Product: BCF2000 [1568546.326275] usb 4-1.6: Manufacturer: BEHRINGER
gafferseed demo
It's hard to find examples of using Gaffer with Appleseed aside from the demo videos.
Here is a project using both the Appleseed linked into Gaffer for an interactive preview and a separate-process Appleseed for a fancier render (with caustics).
gtk font size
Chrome and other gtk programs recently started drawing with a giant font on menus. I tried adjusting X dpi but that did nothing and the numbers already looked ok. Making these files fixed it:
==> /home/drewp/.config/gtk-2.0/settings.ini <==
[Settings]
gtk-font-name = Ubuntu 7
==> /home/drewp/.config/gtk-3.0/settings.ini <==
[Settings]
gtk-font-name = Ubuntu 7
3D printed robot shell
I found a very old robot that bumps into walls and rolls/turns away from them, but its battery case was broken. To mount a new battery case, I did my first printed from-scratch design in blender. I sliced with cura and sent it out with octoprint to my new rostock max v2. I forgot to include supports, but the overhangs worked well enough for this job. There was too much cooling air for the bottom few mm which led to some holes in the walls, but that got better higher up.
Kinect on linux
On Ubuntu 14.04, I got libpcl-1.7-bin and openni-utils and plugged in an XBOX 360 Kinect (older style). It errored like this:
% pcl_openni_viewer
terminate called after throwing an instance of 'pcl::IOException'
what(): void pcl::OpenNIGrabber::setupDevice(const string&, const pcl::OpenNIGrabber::Mode&, const pcl::OpenNIGrabber::Mode&) in /build/buildd/pcl-1.7-1.7.2/io/src/openni_grabber.cpp @ 344 : No devices connected.
zsh: abort (core dumped) pcl_openni_viewer
Then I got it to work like this:
Go to https://github.com/avin2/SensorKinect/tree/unstable/Bin and get the right archive. Install it with
sudo checkinstall ./install.sh
and edit the line that's like
3 - Version: [ v5.1.2.1 ]
to be just "5.1.2.1" to avoid an error. checkinstall lets you track the installed files and uninstall them all with the standard package tools. Note that this wrote /etc/modprobe.d/blacklist-gspca-kinect.conf , so unplug/replug your kinect if necessary.
Now you should be able to run these:
% NiViewer
% Sample-NiSimpleViewer
% pcl_openni_viewer
cjdns network
I set up my first nontrivial cjdns network! The most-connected node is a hosted server. The two on the triangle found each other over wifi. The bottom left one doesn't have a route to the hosted server because of a password mismatch, but it is routing through its neighbor.
I used ansible to push the configs.
I have yet to put my android/debian phone on the network. That's the goal of this: instead of adding more and more openvpn setups, I want my phone and laptop to hop between home and roaming networks automatically.
building insight3d
I tested insight3d to see if it would be suitable for making a 3d model of my house. It is not, but here's how I got it to build on current 2014 opencv:
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/ann_1.1.1/Make-config insight3d/insight3d/ann_1.1.1/Make-config
--- insight3d_original/insight3d/insight3d/ann_1.1.1/Make-config 2009-07-23 16:12:54.000000000 -0700
+++ insight3d/insight3d/ann_1.1.1/Make-config 2014-08-15 22:58:33.565338086 -0700
@@ -72,7 +72,7 @@
$(MAKE) targets \
"ANNLIB = libANN.a" \
"C++ = g++" \
- "CFLAGS = -O3" \
+ "CFLAGS = -O3 -m64" \
"MAKELIB = ar ruv" \
"RANLIB = true"
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/ann_1.1.1/src/Makefile insight3d/insight3d/ann_1.1.1/src/Makefile
--- insight3d_original/insight3d/insight3d/ann_1.1.1/src/Makefile 2009-07-23 16:12:53.000000000 -0700
+++ insight3d/insight3d/ann_1.1.1/src/Makefile 2014-08-15 22:58:41.797545538 -0700
@@ -62,6 +62,8 @@
# Make object files
#-----------------------------------------------------------------------------
+CFLAGS := -m64
+
ANN.o: ANN.cpp
$(C++) -c -I$(INCDIR) $(CFLAGS) ANN.cpp
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/Makefile insight3d/insight3d/Makefile
--- insight3d_original/insight3d/insight3d/Makefile 2009-07-24 08:24:41.000000000 -0700
+++ insight3d/insight3d/Makefile 2014-08-15 22:58:50.277759237 -0700
@@ -6,7 +6,7 @@
all: insight3d
insight3d: $(OBJECTS) sift_detector
- g++ $(DEBUG) -o insight3d *.o `pkg-config --libs opencv libxml-2.0 sdl gtk+-2.0` ./sift/lib/libfeat.a $(AGARLIB) -llapack -lblas -lGL -lGLU ./sba/libsba.a ./ann_1.1.1/lib/libANN.a
+ g++ -O3 -o insight3d *.o `pkg-config --libs opencv libxml-2.0 sdl gtk+-2.0` ./sift/lib/libfeat.a ./sba/libsba.a -llapack -lblas -lGL -lGLU -lgdk-x11-2.0 -lpthread ./ann_1.1.1/lib/libANN.a
sift_detector:
make -C ./sift
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/mvg_decomposition.cpp insight3d/insight3d/mvg_decomposition.cpp
--- insight3d_original/insight3d/insight3d/mvg_decomposition.cpp 2009-07-23 16:13:59.000000000 -0700
+++ insight3d/insight3d/mvg_decomposition.cpp 2014-08-15 22:59:09.462242670 -0700
@@ -29,7 +29,8 @@
bool mvg_finite_projection_matrix_decomposition(CvMat * const P, CvMat * const K, CvMat * const R, CvMat * const T)
{
// extract camera center, i.e. calculate the right null vector of P
- CvMat * W = cvCreateMat(4, 1, CV_64F), * V_transposed = cvCreateMat(4, 4, CV_64F);
+ CvMat * W = cvCreateMat(3, 1, CV_64F), * V_transposed = cvCreateMat(4, 4, CV_64F);
+
cvSVD(P, W, NULL, V_transposed, CV_SVD_V_T); // todo check singular values of P for numerical stability
// check for camera at infinity
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/sift/include/utils.h insight3d/insight3d/sift/include/utils.h
--- insight3d_original/insight3d/insight3d/sift/include/utils.h 2009-07-23 16:13:48.000000000 -0700
+++ insight3d/insight3d/sift/include/utils.h 2014-08-15 22:59:34.934884530 -0700
@@ -156,7 +156,7 @@
@return Returns the basename of \a pathname.
*/
-extern char* basename( const char* pathname );
+//extern char* basename( const char* pathname );
/**
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/sift/src/imgfeatures.c insight3d/insight3d/sift/src/imgfeatures.c
--- insight3d_original/insight3d/insight3d/sift/src/imgfeatures.c 2009-07-23 16:13:49.000000000 -0700
+++ insight3d/insight3d/sift/src/imgfeatures.c 2014-08-15 22:58:46.277658436 -0700
@@ -366,7 +366,7 @@
cvInitMatHeader( &M, 2, 2, CV_64FC1, m, CV_AUTOSTEP );
cvInitMatHeader( &V, 2, 2, CV_64FC1, v, CV_AUTOSTEP );
cvInitMatHeader( &E, 2, 1, CV_64FC1, e, CV_AUTOSTEP );
- cvEigenVV( &M, &V, &E, DBL_EPSILON );
+ cvEigenVV( &M, &V, &E, DBL_EPSILON, -1, -1);
l1 = 1 / sqrt( e[1] );
l2 = 1 / sqrt( e[0] );
alpha = -atan2( v[1], v[0] );
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/sift/src/Makefile insight3d/insight3d/sift/src/Makefile
--- insight3d_original/insight3d/insight3d/sift/src/Makefile 2009-07-23 16:13:49.000000000 -0700
+++ insight3d/insight3d/sift/src/Makefile 2014-08-15 22:59:16.130410697 -0700
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -O3
+CFLAGS = -O3 -m64
BIN_DIR = ../bin
INC_DIR = ../include
LIB_DIR = ../lib
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/sift/src/siftfeat.c insight3d/insight3d/sift/src/siftfeat.c
--- insight3d_original/insight3d/insight3d/sift/src/siftfeat.c 2009-07-23 16:13:49.000000000 -0700
+++ insight3d/insight3d/sift/src/siftfeat.c 2014-08-15 22:59:20.786528024 -0700
@@ -75,7 +75,7 @@
export_features( out_file_name, features, n );
if( out_img_name != NULL )
- cvSaveImage( out_img_name, img );
+ cvSaveImage( out_img_name, img, NULL );
return 0;
}
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/tool_calibration.cpp insight3d/insight3d/tool_calibration.cpp
--- insight3d_original/insight3d/insight3d/tool_calibration.cpp 2009-07-23 16:13:59.000000000 -0700
+++ insight3d/insight3d/tool_calibration.cpp 2014-08-15 22:59:24.038609970 -0700
@@ -257,7 +257,7 @@
ASSERT(points1->cols == points2->cols, "sizes of matrices containing correspondences do not match");
// compute F
- CvMat * F = opencv_create_matrix(3, 3), * status = cvCreateMat(1, points1->cols, CV_8S);
+ CvMat * F = opencv_create_matrix(3, 3), * status = cvCreateMat(1, points1->cols, CV_8U);
if (!cvFindFundamentalMat(points1, points2, F, CV_FM_RANSAC, epipolar_distance_threshold, 0.999, status))
{
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/tool_matching.cpp insight3d/insight3d/tool_matching.cpp
--- insight3d_original/insight3d/insight3d/tool_matching.cpp 2009-07-23 16:13:59.000000000 -0700
+++ insight3d/insight3d/tool_matching.cpp 2014-08-15 22:59:27.394694536 -0700
@@ -387,7 +387,7 @@
{
// allocate structures
CvMat * first_points = cvCreateMat(2, correspondences, CV_64F), * second_points = cvCreateMat(2, correspondences, CV_64F);
- CvMat * status = cvCreateMat(1, correspondences, CV_8S);
+ CvMat * status = cvCreateMat(1, correspondences, CV_8U);
cvZero(status);
CvMat * F = cvCreateMat(3, 3, CV_64F);
diff -x '*.o' -x '*.a' -ru insight3d_original/insight3d/insight3d/tool_triangulation.h insight3d/insight3d/tool_triangulation.h
--- insight3d_original/insight3d/insight3d/tool_triangulation.h 2009-07-23 16:13:59.000000000 -0700
+++ insight3d/insight3d/tool_triangulation.h 2014-08-15 22:59:30.806780512 -0700
@@ -32,6 +32,7 @@
#include "mvg_triangulation.h"
#include "ANN/ANN.h"
#include <set>
+#include "/usr/include/opencv2/legacy/legacy.hpp"
void tool_triangulation_create();
void tool_triangulate_vertices_user();
gfycat bookmarklet
When a big gif animation starts loading (as the only resource in the page), hit this bookmarklet and the gfycat.com proxy will serve you a proper video.
Bookmarklet: gfycat
This is a modification of the code in this reddit comment by joey5755, but mine opens a playing gif in the same window (to hopefully stop the gif download), while joey5755's opens in a new tab.
Using jade with klein
Klein is another python micro web framework that uses twisted's web server (and therefore twisted's event loop system). It looks like this:
from klein import run, route @route('/') def home(request): return 'Hello, world!' run("localhost", 8080)
Jade is an alternate syntax for HTML that's very terse and great for typing and reading. It looks like this:
doctype html
html
head
title
Hello world
body
h1 Hello
ul
each name in friends
li
| Hi #{name}
PyJade is a python implementation of jade. Jade has some template directives in it, which pyjade can render out to other template languages. This means pyjade does its work only once when the template is loaded, and then another template library does the per-page rendering of the template.
I tried jinja2 but the integration didn't work on the first try. With mako templating library it did, though, so here's the result:
import pyjade
from pyjade.ext.mako import preprocessor as mako_preprocessor
from mako.template import Template
from mako.lookup import TemplateLookupfrom klein import Klein
templates = TemplateLookup(directories=['.'],preprocessor=mako_preprocessor)...@app.route('/', methods=['GET'])def index(self, request):t = templates.get_template("index.jade")return t.render(friends=self.friends)
This isn't Klein-specific, of course. It would work with any other web framework that doesn't have a template rendering system that you want to use.
ZyXEL router password length
When a ZyXEL P-663HN-51 ASDL router says this:
Use the fields below to enter up to 16 characters and click "Apply" to change or create passwords. Note: Password cannot contain a space.
nvidia xorg.conf upgrade
My xorg.conf broke when I upgraded to ubuntu 12.10 because of the upgrade of nvidia-current from 295.40-0ubuntu1.1 to 304.51.really.304.43-0ubuntu1. I'm running 2 graphics cards and 3 monitors, rotated, as one big display.
Here is the new xorg.conf file, showing the 'metamodes' syntax and the DPI override I needed to get the right size fonts:
The interesting lines are these for the screens:
Option "metamodes" "DFP-0: nvidia-auto-select @1050x1680 +0+0 {Rotation=right}, DFP-1: nvidia-auto-select @1050x1680 +1050+0 {Rotation=right}"
DisplaySize 720 540
Option "UseEdidDpi" "FALSE"
If you serve http on localtunnel
localtunnel is a cool networking hack that, among other things, can be used to show someone a web server you're working on before it's deployed to a place it can be seen from the internet.
I left such a tunnel open all day, and it had a name like http://51px.localtunnel.com. I somehow got:
6 requests to "GET / HTTP/1.0" 200
7 requests to "GET /robots.txt HTTP/1.0" 404
1 request to "GET /about/privacy HTTP/1.0" 404
1 request to "GET /blog/category/blog/feed/ HTTP/1.0" 404
3 requests to "GET /exercisestats/gecko_ex_buckets?ix= HTTP/1.0" 404