Hacks
OS X ‘delete’ key not working in Terminal Fix
Posted by HokieTux on February 3, 2010 in Hacks
By default, the OS X terminal will not send the proper ‘^H’ character when you press the ‘delete’ key. This isn’t a problem if you are working locally, because the terminal knows how to interpret local keystrokes without issue.
However, if you are SSH’d to a remote machine and/or are using GNU screen, there is a chance that you will no longer be able to backspace properly.
Luckily, the fix is simple. Head into the Terminal preferences, click the ‘Advanced’ tab, and check the box about ‘delete’ sending the ‘^H’ character. It should look something like this on Snow Leopard:
And that’s it! You should be all set =)
Using <complex> vs <complex.h> with g++
Posted by HokieTux on February 1, 2010 in Code, Hacks
Long story short: Including <complex.h> in your C++ source file does not include the C language complex.h header!
After fighting with g++ to get the proper complex numbers implementation working in a recent project of mine, I thought I would post what I discovered in case anyone else finds it useful.
It is fairly common knowledge that use of C-style standard headers in C++ is considered deprecated. By this I mean that if you want to include <stdio.h>, a C library, in a C++ source file, then you should actually include <cstdio>. The same exists for other libraries, e.g. <math.h> is <cmath>, <signal.h> is <csignal>, etc. This has been phased into recent versions of compilers with varying levels of enforcement.
However, not all standard C libraries have been moved over to the new standard. For a long while, <stdint.h>, which includes bit-specific datatype declarations like int32_t and uint64_t, did not have an equivalent <cstdint>. In these circumstances, including the originial <stdint.h> worked just fine, and included the C language header as expected.
This is not the case with <complex.h>.
The C++ standard implementation of complex numbers is a templated type. To declare it, you do something like:
complex<float> mynum(2.0, 3.0);
The C version of complex numbers is an IEEE standard (1003.1), and is declared like so:
complex double mynum = {2.0 + 3.0*I}
If you want to use the C version, you might think all you need to do is #include <complex.h> in a C++ file… turns out that doesn’t work. For whatever reason, g++ will include the C++ templated type rather than the standard C language type.
If you want to use the C version, the easiest way I’ve found is to simply give the absolute path to the include header, like so:
#include “/usr/include/complex.h”
I ended up using the C++ version anyways, but while I was attempting to use the C implementation, this one certainly had me confused for a bit.
Videos Freezing After 2 Seconds
Posted by HokieTux on January 22, 2009 in Hacks
Two work-arounds in one day!
Today, my Flash player seemed to stop working while trying to watch a YouTube video. It would play two seconds (without audio), and then freeze. If I skipped ahead in the video, it would simply play the next two seconds (again, without audio), and freeze.
Googling around, there are a bunch of fixes including re-installing Firefox, deleting & re-installing Flash, and a few others even more drastic including re-installing all media codecs.
I’m still not sure what the problem is, but I think it is in Firefox. All I did to fix it was completely close firefox (I even issued a $ sudo pkill firefox to make sure), reopen Firefox, and told it NOT to reload tabs. Sure enough, video playback was fixed.
If anyone has more information as to what is causing this, please post it!
Firefox version: 3.0.5
Cheers!
Xorg 1.5 & Device Detection
Posted by HokieTux on January 22, 2009 in Hacks
Apparently the Xorg developers have added some sort of device autodetection in one of the recent releases of Xorg server v1.5+
Unfortunately, this seems to be breaking a lot of system configurations – mine included. I have been using HAL and evdev to detect and configure my system input devices, and as soon as I updated xorg to the new release things started breaking. If you are experiencing any of the following:
- Wrong keyboard layout / keymap
- Xorg freezing on startup
- Black screen
- Mouse won’t respond
- Keyboard doesn’t respond
- Mouse actions seem to be really, really sped up (this is a strange one, and seems to only happen in composite window managers)
… then this might be your problem! Here’s the fix:
Head to /etc/X11/xorg.conf, and find the “Server Flags” section. If for whatever reason you don’t have a “Server Flags” section, add it just under the “Module” Section. Now, add the “AutoAddDevices” “false” option (ignore the “Xinerama” option – that was put there by nvidia-xconfig):
Section "ServerFlags"
Option "Xinerama" "0"
Option "AutoAddDevices" "false"
EndSection
Hold onto your helmet and restart X11 – hopefully, things work.
If you are still having problems, feel free to post here and I’ll help if I can!
Cheers!
HowTo: Fix OS X’s self-assigned IP Problem
Posted by HokieTux on August 4, 2008 in Hacks
I recently came back to my old man’s place for a couple of days before we headed out on a vacation, and quickly discovered that my Macbook wouldn’t play nicely with his wireless network. My sister has an iMac that she struggled to make work with the wireless, but had forgotten what she had done to get it up and running.
The issue was that when I connected to the network, I had no actual internet access. I had an IP, and I could ping the router, but I couldn’t get anywhere else. Looking in network preferences, it said:
Airport has a self-assigned IP address and may not be able to connect to the internet.
I spent a good amount of time searching around online and digging through forums for a good fix. There seem to be a lot of different solutions out there, each of which work for a small percentage of the people with this problem.
The fix that ended up working for me was thus:
Add a ‘$‘ to the beginning of the WEP password.
No joke. I deleted the wireless network from the Airport preferences, reconnected to it, and prefaced the password with a dollar-sign… and it worked.
I hope this fix works for someone else out there with this problem. I also hope that Apple gets their shit together and fixes their broken network stack. OS X’s networking stack has always been weak, and Leopard was supposed to change all of that. I love my Mac, but come’on Apple – you can do better than this.
Helpful Threads If This Didn’t Work:
- http://forums.macrumors.com/showthread.php?t=429435
- http://discussions.apple.com/thread.jspa?threadID=1111788&tstart=0
- http://ryanjbonnell.com/journal/self-assigned
