Working with terminal controlcodes

Posted in Uncategorized by Julian Kessel - Aug 03, 2011

I wondered about how to clear a line in a shellscript which uses \r to do a carriage return and reuse the same line to output some text:

While the CR does not clear the contents of the line, you have to do that yourself:

  echo -ne "\033[2K\r"`echo $i | awk '{$1=""; print $0}'`

I use that line to display a string in a loop as described above. The \033 is nothing else than the escaped octal notation of \e which is ESC.

You can find a lot more related info to at http://www.termsys.demon.co.uk/vtansi.htm

Tags: COMMENTS

Using pithos with ssh and without socks

Posted in Uncategorized by Julian Kessel - Aug 01, 2011

Pithos is a native pandora client for linux which uses the pianobar library.

Users with their endpoint outside of the US have the common problems using pandora with tunnels and so on.

If you have a ssh connection to somewhere in a allowed country and being allowed to create port forwardings, this is for you:

Since pithos doesn't allow socks proxys yet you can do an admittedly bad, but working workaround:

get the pandora hosts:

host pandora.com

pandora.com has address 208.85.40.20
pandora.com has address 208.85.40.50
pandora.com has address 208.85.40.80

setup your ssh connection:

ssh user@server -L 8000:208.85.40.50:80

This will tunnel all traffic from localhost:8000 via your server to one pandora server on port 80, you can use another ipaddr if you want.

Now you have to enter http://localhost:8000 in the proxy field of pithos.

That's it :)

Tags: COMMENTS

reboot-safe cfg of thinkpad HIDs

Posted in Uncategorized by Julian Kessel - Jun 02, 2011

I used to configure my trackpoint and touchpad w/ gpointing-device-settings, this way cfgs are non-persistent. I achieved persistency through the following method:

prepend the following to the launch of the wm in ~/.xsession

xinput set-prop 'TPPS/2 IBM TrackPoint' "Evdev Wheel Emulation" 1
xinput set-prop 'TPPS/2 IBM TrackPoint' "Evdev Wheel Emulation Button" 2
xinput set-prop 'TPPS/2 IBM TrackPoint' "Evdev Wheel Emulation Timeout" 200
xinput set-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Palm Detection" 1
xinput set-prop 'SynPS/2 Synaptics TouchPad' "Synaptics Off" 2
xinput set-prop 'TPPS/2 IBM TrackPoint' "Evdev Wheel Emulation Axes" 6 7 4 5

Tags: COMMENTS

Show dd ‘s progress on OSX

Posted in Uncategorized by Julian Kessel - Feb 06, 2011

Simply using kill -USR1 or -USR2 on dd's process id while copying bytes around doesn't work on OSX. You have to use -SIGINFO or -s SIGINFO to achieve that result. Unfortunately trying the first two signals kills the process completely so you have to start from the beginning.

Tags: COMMENTS

scanf vor switch/case und in do/while – ein gcc bug?

Posted in Uncategorized by Julian Kessel - Jan 24, 2011

Mir ist neulich in einer schulischen Arbeit ein merkwürdiges Verhalten des C input managements – ich nenne es mal so,  aufgefallen. Im folgenden Code überrennt das Programm nämlich einfach den letzten scanf() vor einem switch/case Ausdruck sogar! wenn unmittelbar davor den input buffer (stdin) geflusht wird:

#include <stdio.h>
 
int main(){
	char op;
	float inp1,inp2,erg;
	do{
		printf("Bitte geben sie einen Operand ein: "); scanf("%f", &inp1);
		fflush(stdin);
		printf("Bitte geben sie einen weiteren Operand ein: "); scanf("%f", &inp2);
 
		printf("\n(A)ddieren\n(S)ubtrahieren\n(M)ultiplizieren\n(D)ividieren\n"); 
		fflush(stdin);
		scanf("%c",&op); //bug in gcc?
 
		switch(op){
			case 'a': case 'A':
				erg=inp1+inp2;
				break;
			case 's': case 'S':
				erg=inp1-inp2;
				break;
			case 'm': case 'M':
				erg=inp1*inp2;
				break;
			case 'd': case 'D':
				if(inp2!=0.0) erg=inp1+inp2;
				break;
			default: printf("Eingabefehler!\n"); break;
		}
		printf("Ergebnis: %.3f\n", erg);
		printf("Zum Abbrechen [e/E] drücken: ");
		scanf("%c", &op); //kleiner Variablen-reuse
	}
	while((op!='E')&&(op!='e'));
 
	return 0;
}

Die Lösung ist, ein Space vor den Format-String-Typ zu setzen, auf einmal wartet das Programm mit der Eingabe. Warum Ich im Titel und im Code gcc erwähne hat den Grund, dass sowohl mein Lehrer, als auch die meisten Mitschüler ein Altes borland (ca. v5.02) benutzen, bei dem dieses Verhalten nicht auftritt…

Tags: COMMENTS

As I followed this post I ran into this error: /libexec/ld-elf.so.1: Shared object "libintl.so.8" not found, required by "wget"

Luckily, there is a simple workaround for that, simply set a link to an older? version of the library:

<code>ln -s /usr/local/lib/libintl.so.9 /usr/local/lib/libintl.so.8</code>

Write this to the PostInit routines under System -> Advanced -> Command Scripts and you're done :)

Tags: COMMENTS

Creating piezoelectric oscillator symbol in LaTeX

Posted in Uncategorized by Julian Kessel - Sep 25, 2010

{\textSFx\textSFix \fbox{\begin{minipage}{5in}\vspace{10pt}\end{minipage}}\textSFviii\textSFx}

Tags: COMMENTS

I assume you've got a working configuration for any roadwarrior such as your laptop, so I explain only small adaptions. Anyway, for a basic configuration, see http://www.scribd.com/doc/8142908/pfSense-OpenVPN-Tutorial

The setup has been tested with a nexus one running Froyo (FRF91) and Cyanogenmod 6 RC3 and PFSense 1.2.3-RELEASE nanobsd on an ALIX board

Let's start with the PFSense box:
Check LZO Compression #for a slight better performance

Under "Custom Options"

add push "redirect-gateway" #since Cyanogenmod OpenVPN integration has problems with doing this itself…

Now to the Device (all options have to match the ones chosen on your pfsense wall, i think that's self-evident):
Under "Advanced" (press the menu button) choose the following:

Device to use: tun
LZO Compression: true
Redirect Gateway: FALSE #pfsense pushes this option to us
Cipher Algorithm: AES-256-CBC #since my uplink is 1Mb/s it doesn't really matter that I use something really secure, crypting on my nexus1 will do that with ease
Size of cipher key: default

Tags: COMMENTS

Cleaning up / Extending Timetable in LaTeX

Posted in LaTeX by Julian Kessel - Aug 23, 2010

The Class always had a “buggy” behavior for me, so I thought about some fixes for that problems and since I never discovered a better package, I made up fixes for that problems:

The snippet below is for printing the exact begin- and ending times of your lessons, since The class gives the timestring too little space, it grows slightly over the cell border. This “hack” has some exploit flavor.

...
\setprinttimestamps{2} %view also ending time
\settimestyle{\vspace{1mm}\tiny} %_HACK_ push down the Time entries
...

I also recommend adding the command below, if you haven’t already, IMHO the default value is too big.

\setbottomspace{2pt}
Tags: COMMENTS

Android Emulator Dev Tools App on real Device

Posted in Android, Programming by Julian Kessel - Jun 30, 2010

Recent Versions (>=6) of Cyanogenmod and others already include the tools mentioned below, Check that before reading.

Please setup your SDK correctly e.g. w/ this guide:Installing the SDK
There are some Apps preinstalled on the Android Emulator that comes w/ the SDK which you don’t find on the Froyo image or in the Market.

    Start an Emulator Instance and connect your phone in USB-Debugging mode.

Dev Tools” (Developer.apk) [set of tools to view network usage, connections to google servers, view packages install. locations and a whole lot more!]
Spare Parts” (SpareParts.apk) [gives you very detailed info about battery usage of specific hardware and lets you adjust the system's animations]
Custom Locale” (CustomLocale.apk) [quickly fake your locale setting]
“Speech Recorder” (SpeechRecorder.apk) [no guess...]

Ok, so here’s how to get those tools on your device:
Connect Your Android Dev phone via USB and boot the emulator;
run the following bash one-liner:

for file in "SpeechRecorder.apk" "CustomLocale.apk" "SpareParts.apk"; do adb -e pull /system/app/$file; adb -d install ./$file; done
Tags: COMMENTS