Dual Boot Magic

I dual boot on two out of three computers but I really only spend less than 1% of the time in Windows. Occasionally I do find the occasion to bring the red headed stepchild out of the basement. As if this weren’t annoying enough I would often reboot, lack the patience to babysit the reboot, and come back just in time to see that I missed the grub menu and now I have to reboot again. Well some time ago I found a solution to this mess. Enter grub-set-default <num>—this nifty command sets the grub entry to load by default for the next boot only. So I count my grub entries and put the proper number in a nifty reboot script. Alas, by the next time I use this script various Ubuntu updates have changed my grub menu such that now I get some old kernel instead of Windows like I wanted. This clearly wouldn’t do, so I fixed it. Now you can do the same.

Save the following to a script, such as ~/bin/windows.

#! /bin/bash
TARGET=windows
MENU=/boot/grub/menu.lst
ENTRY=$[`grep ^title $MENU | grep -n -i $TARGET | cut -d: -f1` - 1]
sudo umount /media/surfer
sudo grub-set-default $ENTRY
sudo reboot

The umount /media/surfer line just unmounts my network media, speeding up the reboot process working around an annoying Ubuntu bug where the shutdown hangs waiting for network drives even as the network is already down, hence no response from the share and a long timeout.

The ENTRY= line is the interesting part. First grep ^title grabs all the grub entries from which we will count the indexes. Next, grep -n $TARGET prints the line number of the entry we are interested in (Windows) along with the line. cut -d: -f1 splits the line on ‘:’ and returns the first field, the number we want to boot. Finally, grep counts from 1, but grub counts from 0, so $[<stuff> - 1] does bash math, wich is like normal math mostly, and hence we have the proper argument to give grub-set-default, et voila.

You can even put an icon in your panel or desktop that will run this script, giving you Windows in one easy click.

24 Dec 02:48 :: 0 comments :: Comment
Tags: linux, computers, annoyances, cool

Mysterious strftime segfault

Say you're working on a big project. Then at some point you call strftime or maybe ctime and what do you get but a nasty and mysterious SEGFAULT?? What's more you are absolutely sure you have no memory leaks, nothing is wrong with the arguments to the call. Then gdb tells you only that the segfault is happening somewhere deep inside the library call. Furthermore, it works on some platforms but not others, indicating again that memory leak you are sure you don't have. So what do you do but spend three hours tracking down your much doubted memory leak? Well hopefully you find this very post and save those three hours. You see, if time.h is included in another source file, you may have forgotten to include it where you use it. The compiler won't blink an eye. The linker doesn't even complain. Yet somehow it all works dandy until you try it on the TA's computer. So long story short, check your includes.

19 Sep 09:49 :: 0 comments :: Comment
Tags: programming, c, troubleshooting, annoyances, computers, linux

CSApprox

Probably the coolest VIm plugin since netrw, welcome CSApprox! Just put this in your .vim/plugin and away you go with completely transparent and automatic 256 color themes for your terminal vim that look amazingly not unlike the GUI versions of those themes. Just make sure your terminal properly reports 256 colors, and that your vim binary is compiled with gui support (debian flavors do this, but apparently not red hat flavors). If either of these are missing it will give you a little message and delay opening vim, if this is a problem you might want to suppress that output.

I also highly recommend enabling 256 colors via Xresources rather than setting TERM=xterm-256color, this will save headache when sshing in from a less fine terminal or when logging in at the console. A quick google turns up plenty of info on how o set your Xresources with one caveat; if you use uxterm like any sane person would, you need s/Xterm/UXterm/. I’ve also found cases where I need xterm as well, so I simply put all three in there to be safe.


Xterm*termName: xterm-256color
UXterm*termName: xterm-256color
xterm*termName: xterm-256color

25 Nov 09:22 :: 2 comments :: Comment
Tags: linux, programming, computers, cool, vim, colors, terminal, xterm, uxterm, gvim, 256

Mutt Color Theme

Some time ago, being the no good visual designer I am, I decided to put together a mutt color theme. This was no ordinary theme, I’m talking 256 colors! No, don’t worry, the theme doesn’t use all 256 colors.

Aaron’s post prompted me to put up my theme for consumption, enjoyment, and comment. If you want details on how to make the colors work, follow the link above, he did a good job of that already.

Now, the theme and screenshots.

14 Nov 11:45 :: 4 comments :: Comment
Tags: linux, computers, mutt, cool, color, email, 256

White Spaces: Coming to a Technology Near You

In a refreshing break from political posts, I’m going to rejoice in the bounty that is white-space airwaves made free and open. With all TV broadcast going digital, there will be many chunks of EM spectrum between digital TV channels. This is known as white-space, or unused digital TV spectrum. The FCC voted 5-0 to make these unused frequencies available in the same sense CB, 802.11 and walkie talkie frequencies are. What does this mean? Why the big fuss? Well, not only does it mean more frequencies available for wireless internet and other uses, it also means longer range for wireless internet and other things. These are the same frequencies that TV signals are broadcast long distances on, remember. It is very exciting. Some call it wifi on steroids. Along those lines, think Digis (or insert wireless provider here) on steroids. Room for more wireless ISPs and at greater range, therefore less base stations, more customers, more competition, and lower costs all around! But it’s not just about wireless providers, or even just internet, my brother wants to build a GPS receiver that transmits the raw data home for actual position calculation, offloading the hard work, making the mobile unit simpler and cheaper. The newly available spectrum means for him more range and less interference. Exciting times!

11 Nov 11:01 :: 0 comments :: Comment
Tags: technologny, cool, computers, wifi, wireless

Bye Bye smbfs

Please, Von, please, next time you set up a samba mount, just use cifs and not smbfs. Save yourself a lot of headache.

14 Apr 23:42 :: 0 comments :: Comment
Tags: computers, linux, annoyances, troubleshooting, reference

BYU Calendar

I’ve been maintaining a google calendar of the BYU academic schedule for the past year or so. It just occurred to me to let people know about it, though it has been “public” the whole time.

There’s the official gcal button, and here’s the ical and the html. Before this one I was using someone elses. Worked great until he graduated and stopped maintaining it. So if anyone would like “write access” to this calendar as well, just drop me a line. Hopefully we can keep it alive for generations to come.

Actually, I hope BYU will publish an ical version or something else parseable by gcal itself someday. Just keep hoping.

17 Dec 09:14 :: 0 comments :: Comment
Tags: computers, school, byu

Stick it to 'The Man'

In a world frought with restrictive employment agreements how is a prospective employee to protect himself? I believe the reason there are so many undesirable terms is because job seekers are too eager for that next big break or that shiny big company they can put on their resumé. If the companies couldn’t get any bites on these contracts then they would stop mandating them. It’s up to us as the fresh meat on the market to take a stand and decline oppressive agreements. Patience is key. There are plenty of jobs out there and with enough searching and patience I believe you can find a mode of employ that’s not only unrestrictive but that’s mutually beneficial. Seek out that employer you can build a symbiotic relationship with. Work with someone whose goals and values you can make your own. You will be much happier. As such you will be more productive and make your employer happier as well. Dare to love your job, not just what you do, but how you do it and under what terms as well.

15 Dec 00:22 :: 0 comments :: Comment
Tags: computers, programming, cs404

Why Software Businesses Fail

The economics of software and all things digital are fiercely different from standard physical economics. The new economy is radically different because of the radically different nature of the commodities. In the physical economy even the most abundant commodities can only be sold once by a particular entity. If I have a truckload of dirt and sell it to a landfill, my dirt is gone. If I have a software product I can sell it time and time again and still have the product. This sounds great, right? What a wonderful and magical thing I have! There’s a problem. Before when I sold my dirt it was gone. I had to get more dirt to sell to someone else. The buyer of my first load could sell it to my next customer and undermine my market, but I’m not worried about that because that consumer ‘consumes’ the dirt and can no longer reuse it. However, when I sell my software the customer can use, reuse, and even redistribute the software indefinately. We have producers but nothing is consumed! This notion of consumers is so fundemental to the physical economy it’s no wonder the ramifications have continued to baffle business. Instead of trying to understand the fundemental differences, business has tried with only limited success to apply artificial barriers and rules to make the new system behave like the old. The fathers of Free software and OSS understood these differences early on and see the artificial modifications as a gross perversion of a wonderful new thing. There’s only one missing piece to this new economy. In an economy, work is performed, things traded, and both yourself and society are benefited. Again imagine I have dirt, this time it’s magical digital dirt. Once I have the dirt everyone potentially has the dirt also. I cannot sell the dirt, everyone has it! Some have tried making new dirt to turn a profit. So I make some green dirt in hopes of making some money from it. But again, I can’t sell the dirt because once I make it, everyone has it already! Society advances but leaves me behind. If I am to help myself in this brave new world I must abandon the idea that the dirt has any value in and of itself. If I make new dirt it’s because I need it, not because it can be sold. Some companies partially embrace the idea and take red dirt and blue dirt made by others and combine it to make purple dirt. But the same fallacy holds, they cannot sell the dirt! The only thing to do is to use the dirt. Let’s shift gears now and imagine paint is free and there’s an unlimited supply. To sell the paint would be silly, but professional painters can still make money putting logos on buildings and signs, applying the paint to roadways and fences. Say I’m a painter and a customer wants her fence to glow in the dark. There is no glow in the dark paint. I can develop the paint myself or I can pay a developer to get me the paint. The only catch is I must abandon all sense of ownership of the new glowing paint, as must the developer if I hired one. Whether I’m the developer or the painter (or both) I put in the effort to make glow in the dark paint to please my customers, not to have the paint. This is the fundemental ideal that must be applied to this magical world of 1’s and 0’s in order to have lasting success. You must use, modify, and create software for the sole purpose of pleasing your customers. If you try to make and sell one product you will be left behind in the blink of an eye.

30 Nov 10:24 :: 2 comments :: Comment
Tags: cs404, programming, open source, computers

Securing the Screen Door

In this time of increasing digital communication, more and more aspects of our life become targets for digital theft. The problem is exacerbated where the magnificent increases in computing power make it harder still to be secure. The door to our digital home is growing larger and more porous with every advancement in technology and convenience. I am beginning to steer my career towards these security issues. I aim to become a systems security consultant or something of the like. As such I would like to begin by consulting you.

Very smart people are creating some amazing encryption technologies. These are further scrutinized and improved by countless more smart people. Have we realized absolute security? Only time will tell, but enough experts suggest that only sheer computing power stands between these encryptions and their content. If this is the case, the raging growth of computing power will soon rush over our walls. Thus security is not solvable problem, but an ongoing battle.

If a good encryption was all it took then we’d be pretty well off, at least for the present computing environment. Unfortunately, security is not a lock, it’s more like a lock and chain. In most cases it’s a reasonably strong lock on a pathetic chain. If the chain is broken the lock does no good. The weakest link in this proverbial chain is by far the human link. There have been clever ways to reduce this link. One example is the advent of the public/private key encryption. No longer does a single key have to be shared between two parties. Once we had a weak link in the messenger of the key; now it’s no link at all.

However there are still many links of human nature with a high potential for weakness. All to often this potential is fully realized. Such links are passphrases or the safe keeping of the keys. There is hope, though. Just because the human link tends to be disproportionately weak doesn’t mean it has to be. Some general rules for strengthening our security include strong passwords. This doesn’t mean something unpronounceable (let alone memorable). It does mean something that’s not in a dictionary. I like to take words from different languages and phonetically smash them together. Something I like. Something I can subvocalize and remember. Another strength strategy is to increase the number of doors to break through. This is done by varying your passwords. If you have one password for all things all it takes is one password leak, perhaps from your favorite fad web site, and your entire security system comes crashing down. If a different password for every application is too much to remember, perhaps try classes of passwords. Use one password for trivial things, one for run of the mill accounts, and one or many for the real sensitive things, for example. Lastly, never divulge sensitive information over insecure channels, ever!

There are so many more ways the human link can be exploited. The best practice is education. If you’re worried about security you should be constantly educating yourself, finding and strengthening your weakest links. This is especially true if your worried about someone else’s security (your employers, for example). If you are an employer then hire someone who is well educating in the pitfalls and solutions of security, and one who will remain thus educated. If you’re just Joe User, only marginally worried about it, you should at the very least follow the guidelines listed above.

As stated before, security is an ongoing battle, both for the cypher writers and for the humans that use it. It’s a race between technology and technology, between the sly and the savvy. If you just learn something every month and apply it you’ll be far ahead of the masses. Stay on top of the game, even if it’s just through baby steps.

01 Nov 10:13 :: 0 comments :: Comment
Tags: cs404, computers, security

MP3 Woes

IMMS was complaining to me that sox couldn’t read mp3 files to alalyze them. I wasn’t about to let this go on too long, I want IMMS to work to it’s full potential. I tried installing liblame0 and liblame-dev, I even tried libmad but all to no avail. Finally I did apt-cache policy sox. The installed version was some studio version from DeMuDi. I thought if any of the available packages would support mp3 it would be the one from demudi, alas this was not the case. I installed the version from ftp.easynet.fr (PLF) and now I have (readonly) support for mp3. Good enough for me.

15 Jul 12:35 :: 2 comments :: Comment
Tags: copyright, linux, debian, annoyances, troubleshooting, music, computers, entertainment

IMMS Once More

I once again have a working IMMS system. (Finally!) I’m using MPD for the player, my own imms.rb to talk to IMMS, and a history/queue wrapper client to turn MPD’s playlist into—you guessed it—a history (before current song) and queue (after current song).

This has the downside that your playlist isn’t a comprehensive playlist. So if you use a client where you would select a song you wanted to hear from a playlist you might not find it. Not to mention that would also mess up the IMMS behaviour.

My solution is mpremote.rb (which also needs livesearch.rb) to quickly find songs from the library and enqueue (enter) or jump-to (END) any song or group of songs I feel like listening to.

Eventually I’ll make a qt or gtk version of mpremote to be more like xmmsfind_remote (if you still use xmms I highly recommend it). Hans and I are also currently conspiring to make an even better MPD that will queue and possibly talk to imms itself.

15 Jul 12:22 :: 4 comments :: Comment
Tags: ruby, entertainment, computers, programming, music, imms

Instant Unicode Gratification

I was trying to look up some unicode characters and google searches for "unicode this" and "unicode that" weren’t getting the kind of results I wanted. So instead I googled for "unicode lookup" and found this.
This site is just so perfect for a firefox quicksearch. So I added "http://www.fileformat.info/info/unicode/char/search.htm?preview=entity&q=%s" as a quicksearch bookmark, with unicode as the keyword. Now I’ll never have to fuddle around looking for unicode characters again.

05 Jul 16:56 :: 0 comments :: Comment
Tags: web, annoyances, computers

Inline DOC

“Wouldn’t it be nice if I could see an inline text version of .doc attachments?” I thought. That wish quickly became reality in this well-ended story.

Finding a sufficiently constrained search term proved difficult, so I resorted to #utah. I soon received an answer from spr (thanks man!) citing wv. I installed it with apt-get install wv. Then I constructed this line for ~/.mailcap:

application/msword; /usr/bin/wvText '%s' /dev/stdout; copiousoutput; desciption=DOC Text; nametemplate=%s.doc

Now fire up mutt and read that darned email-with-a-doc-attachment with nary a care.

15 Jun 18:52 :: 0 comments :: Comment
Tags: debian, computers, mutt, linux, annoyances

SVWow

I was doing some research into SVG when I stumbled across this. Pretty darn cool. I had no idea SVG was that powerful.

01 Jun 18:25 :: 0 comments :: Comment
Tags: computers, entertainment, programming

Seperation Anxiety

My laptop finally came back. I sent it in sometime in the end of March, around the 27th, they fixed it and sent it back about a week later. After a moment of silence for the re-imaged hd, I plugged it in with excitement, ready to boot up and enjoy my beautiful screen again. As I did this my roommate informed me of some fiery sparks coming from the power connection. “Wha?!” I looked for myself; more sparks were visible. Then I could smell the magic smoke.

I found a loose screw floating around by the power input. I removed it and hesitantly sent the laptop back to HP again. Now here again another week or so later I finally have my laptop back. It works this time and I’ve got linux back on it. It’s good to have you home, dernhelm.

16 May 14:56 :: 1 comment :: Comment
Tags: life, computers

no such file to load -- mkmf

Argh, for probably the 3rd time now I found myself trying in vain for some time to hunt down that blasted mkmf.rb. For future reference, and for anyone else searching, here it is.

On debian and debian based distros (ubuntu, demudi, etc) to get mkmf.rb for building those neato goodies, just apt-get install ruby-dev.

16 May 00:37 :: 0 comments :: Comment
Tags: ruby, programming, debian, computers

Quodlibet idiosyncrasies

I’ve been using quodlibet for a couple weeks now. I actually was introduced to it by my brother Hans some time ago, but it lacked an imms interface so I clung to xmms. Subsequently, xmms managed, in it’s awesome ability to annoy, to drive me away once and for all.

Using quodlibet I now have a couple fun projects ahead of me. First is writing an imms plugin for it. Next is fixing some quirky behaviour involving the play queue. Queue is probably the most awesome media player feature since random/shuffle. It allows you to add specific songs to come next without muddling around with the playlist itself—the playlist can happily remain in random mode or any other mode you can fathom.

Now I describe those queue quirks. If someone wants to tackle them before I get to it, go ahead. Just let me know so I don’t duplicate a work in progress. ;) Both issues seem to arise from the fact that a song in queue is a seperate instance that != the same song in list. This causes problem 1) the playlist doesn’t show the current song as playing or jump to it. Problem 2) likewise, when quiting quodlibet, the queue state, the playlist state, and the current playing song are all saved. However, upon resuming the current song, if derived from queue, fails to register as anything and doesn’t play. I assume this is because song_from_queue != anything_in_list.

17 Apr 12:02 :: 0 comments :: Comment
Tags: programming, entertainment, troubleshooting, linux, computers, music

Broadcast Flag

If you don’t know what the broadcast flag is, or why you should care, read this:

What the Broadcast Flag is and Why You Should Care

An aptly named 3 minute guide.

25 Oct 16:18 :: 0 comments :: Comment
Tags: copyright, computers

Pango made my day

All I can say is wow.

I installed a fresh new distro (DeMuDi) this week, then today my brother logged into jabber. In my client I had him aliased as ‘ច​ិន’ (chen) which was spelled wrong but looked right. Well, this time, it looked wrong, or rather, it looked the way you would expect given how I spelled it. I about fell out of my chair! I updated the alias, spelling it right this time (ចិន) and lo and behold, proper glyph placement, nearly causing another chair incedent.
I quickly tried some more:

  • ខ្មៃ (khmai, cambodian for khmer)
  • ជ្រើសរើស (crəəsrəəs, choose)

Subconsonants, prefix vowells, they all work! Alas, firefox does not appear to be using pango, as I see it’s not exactly working here in the browser.

19 Oct 14:43 :: 0 comments :: Comment
Tags: computers, linux, language, khmer, foo, ខ្មែ

Quirky Queues

So my cups queue, which lives on the appartment server, shared amongst three computers, went “off.” I googled around a bit, and apparently this happens when the queue is accessed whilst the printer connection is not available for whatever reason.

I then had to hunt down the way to restart the queue, restarting cups was not enough. I know how to do it with the web interface, but that wasn’t set up, and I wanted the versitility of knowing the command line magic words.

I searched and browsed to no avail, after which I chanced upon the command cupsenable (using a command line and TAB!).

Magic words: cupsenable <queue>

09 Oct 18:21 :: 0 comments :: Comment
Tags: computers, troubleshooting, linux, debian