photo
Jordan Sissel
geek

Wed, 31 Dec 2003

tic update.

tic is almost ready for the real world, I added a *ton* of features to it today/yesterday (eh, I'm still awake and it's 8am...)

- Tab completion
- Aliases
- Logging
- Timestamps
- Customizable output

It also supports minimal line editing. That is, you can use the arrow keys to cursor around within the input line and edit as you please.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/98
posted at: 07:46

Mon, 29 Dec 2003

xterm -e screen? Something better...

I got tired of losing my terminal sessions whenever I decided I needed to restart X for some reason, or one of my assclown dorm-mates decides to ctrl+alt+backspace my X session. So, instead of enabling DontZap in my XF86Config, I figured I would just use screen to compensate. This wasn't enough, seeing as xterm -e screen would just start up a new screen session completely ignoring the current detached ones and thus defeating the purpose of using screen for convenience. Thus, I wrote a two line script to fix this problem:
#!/bin/sh

SESSION=`screen -ls | grep '(Detached)$' | sed -ne '1p' | awk '{print $1}'`
[ -z "$SESSION" ] && screen || screen -x "$SESSION"

What this does is look for the first detached screen session listed by screen -ls and use it to attach to. If there are no currently-detached screen sessions running it'll start up a new one and running your default shell.

Ok, so how is this useful? Put the script above in a file called "attach" and throw it in ~/bin/ (make that directory if you have to). Make sure you chmod 755 ~/bin/attach! Now change the way you open terminals in your windowmanager to:

xterm -e ~/bin/attach [other xterm opts here] 

And you're good to go :)

Comments: 0 (view comments)
Tags:
Permalink: /productivity/97
posted at: 03:14

Fri, 26 Dec 2003

tik, tac... tic!

So I got bored and started working on an aim client written, you guessed it, in perl. It's console-based and will eventually be very similar to tac, but better. Eventually once I get some bugs and basic features nailed out I'm going to attempt to write both Gtk2 and Curses::UI front-ends for it.

Right now it supports the most basic of features including logging in, messaging, receiving messages, get user info, and aliases. Aliases can be nested, that is you can do:

/alias foo /msg psikronic
/alias bar /foo Hello!
and then call /bar and it will call /foo Hello! which will in-turn call /msg psikronic Hello!. Huzzah.

I also added a /default command which will set the default target to send messages to. You can also do ; some message text to message the person who messaged you most recently (prefix the line with semi-colon). You can also do /default ; to set the default to the person who most recently messaged you.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/96
posted at: 03:48

Thu, 25 Dec 2003

Whew! More updates.

More mason madness happening. Debugged some things I found wrong with, well, everything. I also *finally* added commenting. Thread support was also added (yay recursion).
Feel free to, well, post comments!

Comments: 0 (view comments)
Tags: ,
Permalink: /geekery/95
posted at: 06:42

bourne (sh, ksh, bash, zsh, ...) file descriptor fun

Yeah, so having just figured this out now (I'm sure it's in a manpage somewhere) -
You can open file descriptors at will by doing:

exec 3> file_output

The 3 here is the number of the file descriptor, and can be any number really. What this lets you do now is write to that file descriptor:

echo "Hello there" >&3

Now, if you look at the contents of file_output you'll see that it contains "Hello there" - neat?

To close a file descriptor do this:

exec 3>&-

again, where 3 is the number of the file descriptor you want to close.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/94
posted at: 01:38

poor man's netcat.

This script requires ksh. It makes use of a feature of ksh (zsh supports this too, but differently) called a co-process. A co-process is started by using the |& pipe at the end of a command. The file descriptor you use to write to is >&p. To read from it, you use <&p. Here's an example:
tr 'a-z' 'A-Z' |&
echo "hello there" >&p
exec 3>&p; exec 3>&-
cat <&p

The output is:
HELLO THERE

WTF?! You might be confused, I was when I first started playing with these. What happens is it runs tr 'a-z' 'A-Z' in the background as a co-process. Then it echos "hello there" to the input of tr. To signify that we are in fact done sending input, we have to close the input file descriptor, this is done through 2 statements: exec 3>&p - this opens file descriptor 3 and has it output to the co-process. The next statement, exec 3>&-, tells ksh you want to close file descriptor 3, which in turn closes the input to the co-process. The last line should be fairly obvious: cat <&p - it sends the output of the co-process through cat.
Ok, so you want that script do ya? Look below.

#!/bin/ksh
[ $# -ne 2 ] && echo "Invalid parameters" && exit 1
telnet $1 $2 |&
cat <&0 >&p
sed -e '1,3d' <&p

I won't get into much detail as to how things work here, should be pretty straight-forward. It takes 2 parameters, first being the host and second being the port. It reads from standard input and outputs to standard output.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/93
posted at: 01:00

Wed, 24 Dec 2003

Mason rocks me sideways...

After browsing through the online Mason book (which is free!) I set to work on converting this site from PHP. Oh man is it simple. Doing things in perl is often much simpler than a similar solution in PHP, so this makes me happy.

Comments: 0 (view comments)
Tags: ,
Permalink: /geekery/90
posted at: 03:22

Tue, 23 Dec 2003

PHP -> perl HTML::Mason

I'm going to have a go learning HTML::Mason and in the process of doing so will convert this entire site to mason. I'll be posting updates and neat things I learn here, stay tuned...

Comments: 0 (view comments)
Tags: ,
Permalink: /geekery/89
posted at: 23:13

perl's CGI module

I have overlooked some of the coolest parts of perl's CGI module for the longest time - I've known it can generate HTML but I've always shrugged it off as thinking it can't do what i want it to, i couldn't have been more wrong.

What I'm specifically referring to is form generation. The rest of the HTML generating methods are useless to me (like the h1() method), but I'll focus on the cool form generating ones.
Why are they cool? They simplify your life and make code cleaner - For instance, lets say oyu have this fugly line of code:

$poop = "email_address";
$default = "user@somedomain.com"
print 'Email address: <input type="text" name="' . $poop .  
      '" value="' . $default . '"><br>';

This prints out happy html that looks like this:
Email address:

Now, that print line is pretty damn ugly, but we can easily make it pretty once more by doing:
use CGI qw/:standard/;
print "Email Address: " . textfield($poop, $default) . "<br>";

And the output is:
Email Address:

Neat? Yeah.. What next? More neatness! You have an array you want to turn into a group of checkboxes...

use CGI qw/:standard/;
@foo = ("check1", "foo", "bar", "baz", "poopie", "hello", "Coke!", "Pepsi?");
@def = ("foo", "bar", "poopie");
print 'Checkbox listing:<br>';
print checkbox_group(-name => "options", -values => \@foo, 
                     -columns => 3, -defaults => \@def);
print '<br>';
What does this look like?

Checkbox listing:
check1bazCoke!
foopoopiePepsi?
barhello

Comments: 0 (view comments)
Tags:
Permalink: /geekery/88
posted at: 20:14

Sun, 14 Dec 2003

redbull+perl=hottness

The 2nd annual Redbull Coding Competition was held here at RIT, and oh was it awesome. 12 straight hours of teams of 3-5 people coding in various languages trying to attain one of the given objectives and while consuming insane amounts of redbull.

My team went to work with perl and we pushed out a half-decent graphical filebrowser and our remote team-member, pete, finished up the compression objective in record time. The whole competition was a hell of a lot of fun.

<3 perl.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/84
posted at: 16:37

Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '08 Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials SSH Tunneling (Video)

Tag Cloud

Calendar

< December 2003 >
SuMoTuWeThFrSa
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
28293031   

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati