MySQL selecting IPs via CIDR

Quick little snippet here for selecting IPs from a database based off a CIDR subnet. First off a table structure with some test data:

Now let’s say we want all IPs from the subnet 173.192.175.16/28, using a simple 173.192.175.% would provide false results since you don’t want the whole /24. If your IP is stored as an unsigned int (good for you) than you can use this snippet to search for matching IPs:

If your IP is stored as a varchar (for whatever reason), the only difference is a inet_aton() around the IP field.

No matter which one you use, the result will be:

Continue reading

Moving to the USA

I haven’t posted here for a while. One of the reasons is that I started posting more day-to-day stuff on facebook, but the main reason was that the last few months my wife and I have been busy organizing stuff. She got a job offer over here, so December and January we were busy getting everything organized to move from Germany to USA. In December we flew over for a week to get an apartment rented, buy a car, set up a bank account, insurance, … all the fun stuff you go through when moving to a new place. Let it be said, that christmas time is not the advised […]

Continue reading

Windows reinstall and Adobe fun

I never got around to posting it, but a few weeks back the hard drive of my PC with Windows on it died … a little bit. Technically a large chunk of the harddrive is simply unaccessable. after poking and pushing I at least got windows to boot up again, but a large part of the software was dead. I bough a new drive and went through the fun process of installing a fresh windows, patching it, and then installing all the software again. I didn’t get around to installing my video and picture software on the new windows until this morning, and it turned out to be lots of […]

Continue reading

Controlling SSH identities

SSH has a few strange undocumented “features”. One of which is the way it handles identities via agent and command line. It is possible to specify an identity file to use for ssh via the -i parameter (ssh -i identity_file $host). What the manpage doesn’t mention, is that the specified identity isn’t forced for the connection, it is just added to the list of possible identities. To make matters worse, ssh tries the identities from the agent first. So if agent forwarding is enabled and valid for the destination the ssh command will never use the identity specified with -i. Why is this “bad”? Because the identity specified may be […]

Continue reading

a bit of Baking

Wife did some baking tonight, so I whipped out the camera and took some shots. Unfortunately I noticed that the flash hot shoe seems to have gone unresponsive after a fall a few weeks ago, but using the built-in flash as a commander to control an off-camera flash still works fine.

Continue reading

XEN 3.4 with ipv6 routing

Yes, there are a few postings out there about getting ipv6 routing running with XEN. But I’ll throw this online anyway since there are a few changes I had to make for it to work on my server. This text is intended for people who know their way around Linux and XEN so it will be a bit technical and won’t spell out every single step you have to make. Most of the changes are based off scripts and information from BenV and wnagele (latter is interesting for me since I am also running XEN on a hetzner server). Have a look at the two links if anything is unclear. […]

Continue reading

Script of the day – clean up stale .ssh/known_hosts

This little script takes an IP or hostname as a parameter, and if there is an offending key in the .ssh/known_hosts it removes it and replaces it with the current valid one useful if you are moving/reinstalling a large amount of servers …

Continue reading

Checking a list of IPs against RBL

This is more a reminder to myself than anything else … this is small snippet that takes a list of IPs and does a whois on all that aren’t in a RBL Lets say we have al list of IPs in a file “iplist.txt”: 12.172.121.171 24.149.208.68 38.105.100.9 58.185.207.86 61.201.51.66 64.78.164.169 Snippet that checks the IPs (can of course be easily changed to check IPs that are IN a RBL)

Continue reading

bash: using the content of a variable as variable name

Since the implementation of Arrays in Bash is somewhat lacking compared to higher level programming languages (only one-dimensional), and hash lists require a bit of work to set up, you may run into a situation where you have a small list of key/value pairs that are both variable and you need to store. There are various solutions for the problem, e.g. creating two arrays (one for the keys, one for the values, and combining them by using the same index values for the entries), or using the functions from the link above to build a hash list. For me the easiest way to solve the problem, if I only have […]

Continue reading

back online

The hard drive crash threw me offline a few days due to strange problems with software raids, Xen and acpi. Turns out that using the latest Xen kernel from debian testing branch on a software raid only works of you don’t set “acpi=off” as a kernel parameter. If acpi is turned off, the script “scripts/local-top/mdadm” in the initrd can’t find the devices needed to mount the software raid … causing the whole boot process to come to a grinding halt. If I find some time I’ll do some more tests, untill then my server will be running with acpi turned on btw. the hard disk replacement was easy. after the […]

Continue reading

dead hard drive

It seems that one of the hard drives in my server died last night. Thanks to the raid no data is lost, but the server will be offline shortly this week (tuesday morning probably) to replace the faulty drive with a fresh new one.

Continue reading

Pictures from the Mediterranean cruise

We shot over 600 photos on our cruise. Anyone who missed it on Facebook: we visited Savona (Italy), Barcelona, Palma de Mallorca (both Spain), Tunis (Tunisia), La Valletta (Malta), Cantania and Rom (both Italy). Anyway, here is a selection of some of the photos. Took me the better of the day to sort out which photos were worth while posting, and then post-processing them.

Continue reading

Adobe Lightroom 3

I always shoot in RAW + JPEG. For normal point-and-shoot vacation stuff I’m generally satisfied with the JPEG the camera spits out. But I would never shoot only JPEG. The additional information of RAW shouldn’t be underestimated, and to be honest I often tweak around. It makes a difference if you are working on the original RAW data, or if you are working on the JPEG copy the camera has already processed. Up till now I’ve been post-processing my images with Adobe Bridge and Photoshop CS3. Since I was planning on post-processing a whole load of pictures I decided to see what software there is out there to streamline the […]

Continue reading

Ubuntu upgrade to 10.04 and lirc

Ubuntu 10.04 (lucid) came out a short while ago … and because it contained new themes and the latest version of mythtv, I went and upgraded. These updates are tested by gazillions of people, any serious problems would be noticed before release .. right? right? Well, looks like I did it again. Turned a working tv recorder into a “electronic beeping thing under the TV that doesn’t do much except show a pretty screensaver if you wait long enough”. After fixing up some stuff that the update broke (thanks for overwriting my config files. I’ll just use the version from the backup I made before the update if you don’t […]

Continue reading

XEN and Kernel update

Server is up and running again. This morning I finished the xen (3.4) and kernel (2.6.32) updates I prepared yesterday evening. The only pitfall I stumbled across, was that the kernel in the debian repository (2.6.26-xen) seemingly wasn’t compatible with the latest xen in the debian repository (system would hang while booting, I guess that’s what I get for using “testing”). Here are a few tips to make the transition a breeze ….

Continue reading

Grid clicker script

I finished up my “grid clicker” script. it is intended to simplify testing of games where you have to click certain patterns (a grid). Typical facebook games like farmville or funfari are great examples of this. just download the file (here is the sourcecode), execute it, and an eye should appear in your task bar. Double clicking on the icon in your task bar will start the script, just follow the instructions and everything should be fine. And while I am at it: here is a spreadsheet I started for plants/trees/animals in funfari: Google online spreadsheets

Continue reading

Wedding & Photography

I haven’t posted anything here in a while. Mostly I’ve been busy preparing a photo-shoot and -documentation of a wedding of friends. As a photographer you will always notice things, when looking at the finished fotos, where you say “hmm, maybe a differnet aperature/iso/flash/exposure setting would have produced an even better result”. but all in all I’m satisfied with the results.

Continue reading