Homunculus

2010-08-23

Installing Debian over PXE (from a router)

Filed under: Howto — Tags: , , , , — runejuhl @ 14:37:19 UTC

I recently bought a small Mini-ITX computer that I intend to use as a server at home. I pulls around 50 W, has SATA and USB, and was a lot cheaper than investing in a Guruplug or similar. That’ll be next time.

As it doesn’t have either floppy or a disc drive and as my preferred method of using USB disks was to no help as I couldn’t find any due to recent moving activity and everything being packed in boxes, I had some trouble finding out how to install Debian onto it.
One of the few things that I’ve recovered from the boxes is my trusty ASUS WL-500gP router, slightly modded to have a DB-9 RS232 port for serial console and running the latest release of OpenWRT. (more…)

2010-02-12

Using find, xargs and scp to copy multiple folders

Filed under: Uncategorized — Tags: , , , , , — runejuhl @ 15:04:02 UTC

I had to find some folders I figured I probably had somewhere in a big mess of a directory structure, and subsequently upload the found folders to a remote site.

The following oneliner demonstrates the flexibility of both find and xargs:

find . -type d -name \*FUTURE\* -or -type d -name \*[fF]ilur\* -or -type d -name \*Cape\* | xargs -I{} scp -r '{}' runejuhl@pluto.example.org:copied/

In this line, we use find to find directories (“-type d”) which contains either “FUTURE”, “[fF]ilur” or “Cape”, and pass the found directories along to xargs. The letters in square brackets are part of a regular expression that allows either “f” or “F” only once.

xargs takes the directory paths from stdin and executes the command after the “-I{}” argument. “-I{}” means that we, instead of usual behavior where xargs just appends stdin to the command, want to have a bit more flexibility. In this case, xargs replaces all occurences of “{}” with the input from stdin. The single apostrophes around “{}” ensures that xargs won’t choke on any spaces in the directory names.

2009-08-27

Ignoring file collisions on Gentoo distributions

Filed under: Uncategorized — Tags: , , , , — runejuhl @ 11:53:13 UTC

I recently converted from Ubuntu to Debian to Sabayon, the latter being a Gentoo-based distribution with support for binary packages. Best of two worlds, I thought.

It really is great, too. Everything works out of the box. Being Gentoo-based, there are always a few hassles until you figure it all out. I’m a former Gentoo user, but it’s been some time since I’ve used it, and I think that most of the errors are due to the binary package manager of Sabayon.

Either way, I’ve been experiencing quite a few file collisions:

* Package 'app-cdr/cdrtools-2.01.01_alpha61' NOT merged due to file
* collisions. If necessary, refer to your elog messages for the whole
* content of the above message.

You can use the environment variable FEATURES=”-collision-protect” to disable collision protection, you can add the variable to your make.conf, you can resolve the collisions manually, or, if you believe in karma, do like I’ve learned:

fruitfucker ~ # COLLISION_IGNORE="/usr" emerge cdrtools -va

With this simple variable, you’ve now chosen to ignore all collisions in /usr. Be aware that this might be fatal, depending on the conflicts. You can use portageq to check collisions manually:

fruitfucker ~ # portageq owners / /usr/include/schily/fnmatch.h
None of the installed packages claim the file(s).

If you’re sure that you have a decent karma rating, i.e. “good” or better, you go ahead and use COLLISION_IGNORE. If you’re not quite sure about your karma status, remember to lean your bicycle against a wall or another solid object (reliance on bicycle stands burns karma), pick up empty plastic shopping bags (trash) and make sure to smile at old people — sometimes they really do deserve it!

Thanks to crox @ crox.net for providing me with this solution: http://blog.crox.net/index.php?url=archives/49-Gentoo-Linux-Package-NOT-merged-due-to-file-collisions-problem-and-solution.html&serendipity[cview]=linear.

How to live your life despite NAT

Filed under: Uncategorized — Tags: , , , — runejuhl @ 10:50:47 UTC

Hello readers.

Today we’re going to talk about port forwarding. We all know someone who’s affected by the NAT plaugue — wan’t to know how to cope with it?

Well, you could always do like me. I use autossh together with SSH key authentication to route data from a specific port at a server I always have access to, to my desktop computer at home.

ssh -R 2222:localhost:22 ssh.at.university.tld does exactly that.

From my laptop (or whatever computer I’m using), I do the opposite, route a port from the university server to my laptop:

ssh -TNf -L 2222:localhost:2222 ssh.at.university.tld

There are a lot of SSH flags, so there’s plenty of things to play with. Compression is awesome when I’m taking the train and surfing using GRPS. On 9.6 KBps it feels like 1996 again, though.

After that, I use my tunnel to set up SSH with dynamic routing:

ssh -NfD 8080 ssh.at.university.tld 2>&1
ssh -NfD 8081 -p 2222 localhost 2>&1

In Firefox I use FoxyProxy to easily switch between the two proxies, and what this setup I can pretty much switch seamlessly between 3 proxies. If you use Firefox as well, be sure to set network.proxy.socks_remote_dns to true in about:config.

Of course, it helps that I’m usually connected to the internet through the university connection and that my home desktop is on a 100 Mbps connected — part of the research network here.

Here is the relevant snippet from the SSH man page:

-D [bind_address:]port
Specifies a local “dynamic” application-level port forwarding. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root can forward privileged ports. Dynamic port forwardings can also be specified in the configuration file.

Port ahoy!

Google div content size restrictions

Filed under: Uncategorized — Tags: , — runejuhl @ 09:45:04 UTC
80em on 1920x1200 isn't nearly enough.

80em on 1920x1200 isn't nearly enough.

Either I just haven’t noticed before, or Google has updated their CSS, but the content div has a max width of 80em. Which, on my still-going-strong Dell 2405 FPW 24″ 16:10 LCD is not nearly all of the page.

The corresponding code is here:

#cnt{max-width:80em}

Maybe I should find a plugin for displaying 2 tabs at a time?

2009-08-12

Resuming a scp transfer, or making your life more enjoyable with rsync

Filed under: Uncategorized — Tags: , , — runejuhl @ 10:32:57 UTC

When you find yourself in a small house in a small fishing town in Sweden, surrounded by the beautiful nature, you sometimes long home for the data you left behind. When you can no longer suppress your needs for new data (like the data vampire you are), it’s lines like these that make life easier:

rsync -av -e 'ssh -p 22022' runejuhl@localhost:/media/disk1/pictures/holiday/2009/ .

This line synchronizes two directories. The “-av” flags sets archive and verbose modes, the “-e” flag and following additional argument tells rsync that we want to use ssh on port 22022. The rest is just two paths; one on the remote computer, one on the local computer.

The benefit of this over just using plain scp, is that with rsync you are able to resume transfers of whole directories easily. Files updated? Just re-run.

2009-06-16

How to find out if you’ve been scammed

I recently stumbled upon a 16 GB flash drive on eBay, and from the beginning I was suspicious; after all 9.5 GBP isn’t a lot, considering the item had free shipping. Oh well, it was a last minute buy, and I hit the buy button a mere 20 or 30 seconds before the auction ended.

I received the flash drive in the mail a few days ago, and within a few seconds of getting within range of my computer, I had plugged it in, and ran dmesg to see if it produced any strange output: (more…)

2009-06-07

Using WAVE files as input/output in LTSpice

Filed under: Uncategorized — Tags: , , , , — runejuhl @ 17:48:01 UTC

LTSpice is pretty versatile in terms of input — it’s possible to take your input from a WAVE file and pipe the output to another WAVE file, which is great if you’re building audio amplifiers.

Using WAVE files as input

In these SPICE directives the transient analysis is set to a length of 30 seconds, beginning at t=0. .four, the Fourier transformation function of LTSpice has been used previously, but is now commented out. In the final line, the .wave directive is set up. out2 is referring to a label at the place we want our output.

In these SPICE directives the transient analysis is set to a length of 30 seconds, beginning at t=0. As opamps are used in the simlation, the directive is included. .four, the Fourier transformation function of LTSpice has been used previously, but is now commented out. In the final line, the .wave directive is set up. out2 is referring to a label at the place we want our output.

Using WAVE files as input is pretty straightforward. Instead of using a traditional voltage source as input for your circuit, replace the voltage expression with a WAVE-file expression:

wavefile="z:/home/runejuhl/kashmir.wav" chan=0

In the expression above, the path refers to a file when using LTSpice through WINE on Linux. The path can be expressed as either a full path or a path relative to the location of the circuit schematic file.

chan” refers to the respective channel in the WAVE file used for the simulation, and can be a number between 1 and 65535 — although usually channel 0 refers to the left channel and channel 1 refers to the right channel.

Using WAVE files as output

Wave in

The WAVE file kashmir.wav acts as a voltage source. Only channel 0, the first channel, is used in this simulation. The lower voltage source is constant, used in this example to bias the input from the WAVE file with +6V.

Using LTSpice, it is extremely easy to export the output as a WAVE file. The following SPICE directive is used for this:

.wave "z:/home/runejuhl/out3.wav" 16 44100 out1

In the directive above, the path is full path, 16 refers to the bitrate, 44100 is the sampling frequency and out1 is referring to a label in the circuit.

Although not confirmed, it seems that the output has to be in the range between -1 and +1V.

General considerations

  • Simulations take a long time. Even if you use the .tran directive to only simulate for a short while, it seems to take just as long to start up the simulation as if you’d used a full song-length WAVE file.
  • Redrawing the screen is a pain in the ass. Clear all plots before simulating to help yourself later on.
  • The number of channels, the frequency and bitrate can be set as needed. If you want to be able to listen to the output WAVE file, you need to make sure your music player understands the output. For regular persons this means 1 or 2 channels, 8 or 16 bit/channel and a sampling frequency of 11025, 22050 or 44100 Hz.

Notes

I’m using LTSpice through WINE, which is why the paths in the pictures are a bit weird.

On finding EAGLE packages

Filed under: Uncategorized — Tags: , , , , , — runejuhl @ 13:18:49 UTC

I use EAGLE CAD for my electronics projects. It’s a great editor, albeit with a somewhat steep learning curve. The interface is straight-forward, but the key combinations are weird, to say the least.

Today I needed a package outline for (one of) my newest purchase(s); the National Semiconductor LM2677. Bought on eBay for a few USD a pop — apparently they cost around 60 DKK in Denmark. The package is TO220-7, and I didn’t feel like making my own, I have to do that plenty already. More on that in another post.

I figured that one of the other EAGLE libraries already had a nice package that I could just copy, but I couldn’t seem to find any on my way through the list. So, what do you do?

…well, I decided it was time for a new bash oneliner:

for i in `ls *.lbr`; do echo $i; strings $i | grep -A 10 -B 10 TO220-7; done | grep -A 10 -B 11 TO220

The line finds all files ending in “.lbr” in the current folder, echoes the name of the file, uses strings to extract readable strings from the library, uses grep to search for “TO220-7″ and finally uses grep again to extract the interesting part of the output. Output:

runejuhl@runejuhl-laptop:2009-06-07 22:04:40:/opt/eagle-5.6.0/lbr
$ for i in `ls *.lbr`; do echo $i; strings $i | grep -A 10 -B 10 TO220-7; done | grep -A 10 -B 11 TO220
burr-brown.lbr
<b>Mini Small Outline Package</b>
<b>Dual In Line </b>
<b>Small Outline Package</b>, large
<b>Dual In Line </b>
<b>Small Outline Package</b>
<b>Small Outline Package</b>, large
<b>Small Outline Package</b>, large
<b>Small Outline Package</b>
SOT23-5
<b>Small Outline Transistor</b>, 5 lead
TO220-7
<b>Molded Package</b>
<b>DPAC<b>
<b>Metal can Package</b>
SSOP20DB
<b>Small Shrink Outline Package</b>
SSOP24DB
<b>Small Shrink Outline Package</b>
<b>Small Outline Package</b>
SOJ28-4
<b>Small Outline J-Lead Package</b>

And there you go. The first line of the output tells you what library contains the TO220-7 package.

Powered by WordPress