Mar 4 2010

Remove Title Bar on Android Application

xiao

This one’s real simple. If you want to get rid of the title bar in an Android application, you can do it programmatically with:

requestWindowFeature(Window.FEATURE_NO_TITLE);

or in the manifest for your entire application inside the ‘activity’ element with

android:theme="@android:style/Theme.NoTitleBar"
Source

Dec 8 2009

Arpspoof, Tcpkill, Tcpnice Tutorial

xiao

Notes to self because I never remember

To arpspoof, turn on IP forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward

with Linux (might need su) or more permanently,

net.ipv4.ip_forward = 1

in /etc/sysctl.conf
Continue reading


Dec 8 2009

BackTrack 4 Pre-Release Apache, PostgreSQL Autostart

xiao

BackTrack 4 is in pre-release and it’s a beautiful system. However, there seems to be a problem where after your first apt-get upgrade, the system will try to load Apache, PostgreSQL and other daemons on startup. Not exactly what you want when you want a clean system. To turn it off and prevent autostart:

sudo update-rc.d -f apache2 remove
sudo update-rc.d -f postgresql-8.3 remove
sudo update-rd.d -f dhcp3-server remove

This way, you can go on doing your thing without anything that leaves you open


Dec 6 2009

Wireshark, No Interfaces on Mac OS X

xiao

Just so I don’t have to look this up ever again,

chown [you] /dev/bpf*

So you have the permission to those Berkeley Packet Filters needed for capture


Nov 30 2009

Python Log Stdout to File

xiao

Python has the ability to alter its sys.stdout as to redirect its print commands to pretty much anything.

If, for instance, you want to print to both standard output and to a log file, you can create a class to handle the stdout like such:

class MyOutput():
    def __init__(self, logfile):
        self.stdout = sys.stdout
        self.log = open(logfile, 'w')
 
    def write(self, text):
        self.stdout.write(text)
        self.log.write(text)
        self.log.flush()
 
    def close(self):
        self.stdout.close()
        self.log.close()
 
sys.stdout = MyOutput("log.txt")
print "blah blah blah"

Continue reading


Nov 29 2009

Windows 7 Spooler Continuously Stops on Every Print Action

xiao

Spooler simply stops every time you try to print or add a printer or something? You can keep restarting it but will never be able to print something? I won’t pretend to know your problem since it depends on potentially so many things but if you have a MacBook, one thing worth investigating is have you been running VMWare Fusion? The ThinPrint drivers of the VMWare Tools seem to be able to cause this problem when you run the same machine in BootCamp mode. Unfortunately, you can’t just uninstall it. Uninstalling VMWare Tools from inside virtual mode seems to solve this problem


Nov 24 2009

Google Android 1.6 Camera Exposure

xiao

While developing an image processing software on G1, we noticed that our pictures are constantly overexposed although the API seemed simple enough and that we don’t have that many parameters to play with. Especially at API level 4.

Turns out, we need to make use of Camera.autoFocus() to adjust metering from the G1. It’s a bit lame that we can’t set them separately…


Nov 14 2009

PyQt and Snow Leopard

xiao

There are some 64-bit related issues when using PyQt and Snow Leopard. There’s the way to resolve it by reverting to 32-bits:

  1. Get the latest versions of PyQt and SIP. You need Qt installed of course.
  2. Configure SIP using
  3. python configure.py --arch i386
  4. Configure PyQt using
  5. python configure.py --use-arch=i386
  6. Finally, make sure your python is running in 32-bit mode because current Qt doesn’t support 64-bit mode. Add
    export VERSIONER_PYTHON_PREFER_32_BIT=yes

    to your .bash_profile in your home directory

  7. If your Python still refuses to run in 32 bit mode, try
    arch -i386 python

Oct 24 2009

Multi-Threading and Delegates Tutorial in VB .NET

xiao

This guide will show you everything you need to create a non-GUI multi-threaded application in VB .NET.

There are 2 ways of using multi-threading in VB .NET. First by making use of delegates which I will explain here. And second by programming the threads manually (not actually more complicated).

Using delegates, .NET helps simplify the entire process of using a separate thread and saves you from having to manage the parameter passing, result retrieving and timing issues. Continue reading


Sep 13 2009

Empty Home Directory in Windows Using Boot Camp 3.0

xiao

ls -a

Just got Snow Leopard and installed Boot Camp 3.0 on Windows? Boot Camp 3.0 is definitely a well welcomed update. The trackpad works much better now with 2 finger tap for secondary click, it finally works like in OS X. Even better, you can now access HFS+ without third party apps in Windows. Definitely nice for Windows 7 x64 users that MacDrive doesn’t even support. But one problem that seems to trouble people in the forums is that navigating to /Users/[yourname] in Windows shows an empty folder. You can’t access your music or pictures or anything from Windows.

One possibility is the presence of a .Xauthority file in your $HOME directory. Delete the file and you may access your home directory in Windows. Remember that running X11 will recreate the file. Delete it again. Continue reading