Monday, December 29, 2014

How to get project version in waf

You know that line near the top of your topmost wscript file:
VERSION = '1.0'
so you want to get that in another wscript file? So did I. And after going through waflib code, this is the only way I could come up with:
from waflib import Context
version = getattr(Context.g_module, Context.VERSION) 
 
 
 

Friday, October 31, 2014

Converting a Raspberry Pi into a wireless access point

So I have a Raspberry Pi B+ and an RTL8188CUS based wifi dongle. I mostly used these instructions, but hostapd was not working so I did as this post suggests. I downloaded the custom RealTek hostapd, compiled and run it. Don't forget to update /etc/hostapd/hostapd.conf. This is mine:

# Basic configuration
interface=wlan0
ssid=Mistborn
channel=1
#bridge=br0
# WPA and WPA2 configuration
macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=wireless1
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# Hardware configuration
driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek

That's about it.

Wired cannot ping wireless and vice versa

This was driving me crazy. My wired devices on the home network could not ping wireless devices, and wireless devices could not ping wired ones. I was going through the router options over and over. Firewall was disabled and so was user isolation. In the end, I found a "Multi-AP Isolation" in basic wireless settings. I disabled it and voila! Everyone can see everyone now!

Just for the record, the router was a D-Link DSL-2730U ADSL modem/router.

I also found out that I can ssh into my rooter with "root" as both username and password. Maybe I should try messing with it some time. Not today though!

Wednesday, October 29, 2014

Change attachment encoding in mutt

If you want to change the encoding used for an attachment while sending an email with mutt, choose the attachment and then press C-e. It then lets you type the content transfer encoding. You can find the possible values here.

Saturday, September 27, 2014

Suckless Terminal (ST) slow with tmux

ST (Suckless Terminal) sounds cool, but when I decided to give it a try it turned out that when combined with tmux, it is noticeably slower. Switching windows in tmux, whish is instantaneous in urxvt, visibly lags in st.

The workaround I've found at the moment is changing the value of the `termname` variable in config.h from "st-256color" to "xterm-256color".

Pretending to be xterm seems to pay off. So much for getting rid of xterm legacy!

Thursday, May 15, 2014

Building Box2D on Linux

I wanted to build Box2D v2.3.1 on my Ubuntu 14.04 machine. It took me a lot of tweaking to do it, so I thought I'd document the process here.

First I tried the instructions I found here but I got these error messages:

CMake Error at CMakeLists.txt:29 (add_subdirectory):
  add_subdirectory given source "freeglut" which is not an existing
  directory.

CMake Error at CMakeLists.txt:30 (add_subdirectory):
  add_subdirectory given source "glui" which is not an existing directory.

-- Configuring incomplete, errors occurred!
I searched a bit and found out that cmake is no longer supported on Box2D I had to use premake. I ran "premake gmake" in Box2D directory, but I got:

No Premake script found!
Okay. This was easy to fix. I needed premake4, not the older version in Ubuntu's repositories. I installed the latest stable version of premake from premake website. This time, running "premake4 gmake" got me this:

/path/to/box2d-2.3.1/Box2D/premake4.lua:26: attempt to call global 'vpaths' (a nil value)
A bit more searching, and I found out I need the latest version of premake, that is the beta version. All right I got premake4.4 (beta) and this time it ran successfully. I switched to Build/gmake directory and ran "make".

At first things seemed to be going smoothly until I got lots of errors regarding undefined symbols belonging to glfw and glew. But I had the development packages for both of those installed. A lot of poking around and I managed to fix it at last. This is what I did.

  1. Compile and install the latest version of glfw (3.0.4) from source.
  2. Change this line in Build/gmake/Testbed.make:

    LIBS      += $(LDDEPS) -lX11 -lGL -lGLU -lglut

    into this:

      LIBS      += $(LDDEPS) -lX11 -lGL -lGLU -lglut -lGLEW -lglfw3 -lX11 -lXxf86vm -lpthread -lXrandr -lXi
And now, at last everything compiled correctly.

Tuesday, May 6, 2014

Transparently proxifying certain machines in the network

I use an Ubuntu box as a wifi access point/router in my home network. I wanted to transparently proxify certain machines on the network (mainly my Kindle paperwhite --long story!). I finally managed to do it like this:

sudo iptables -t nat -A PREROUTING -m mac --mac-source "MAC-ADDRESS" -p tcp --dport 80 -j REDIRECT --to-port 33128
 In which MAC-ADDRESS is the mac address of the machine I want to proxify. A squid instance is listening on 33128. I had to change this line in my squid configuration:

http_port 33128
to this:

http_port 33128 transparent
so that squid handles transparent proxy-ing correctly.

I'm using iptables version 1.4.21 on Ubuntu 14.04, and squid version 2.7.

Monday, April 7, 2014

"Really" enabling CGI in apache

This was driving me crazy. No matter what I did, apache just did not run CGI scripts. I did all the things people had said on various websites, like adding "AddHandler cgi-script .cgi" or adding "+ExecCGI" to options, but it did not work.

And finally, after hours of searching and trying, I got a hint from a very old apache documentation page that mentioned modules being enabled. I looked at my /etc/apache2, found two suspicious mods-available and mods-enabled sub-directories, confirmed that there was nothing called cgi in mods-enabled, symlinked anything with "cgi" in it from mods-available in mods-enabled, and at last, at long last, I got bugzilla working. Phew!

Sunday, March 16, 2014

Using clang++ with waf

As far as I can see, the only way to make waf use clang C++ compiler is to run it like this:

$ CXX=clang++ ./waf configure

This makes waf use clang++ instead of g++ which seems to be the official way of doing this as it is mentioned in the documents here, except that the current documentation says to run it like this:

$ CXX=clang ./waf configure

which did not work for me. Apparently this causes the wrong standard library to be used.