Tag Archives: tips

Gentoo Love: Intro to Portage Sets

A few quick gentoo tips before we get to the instructional material.

  1. Emerge world as often as you can. Once a week is probably a good frequency.
  2. Unless you’ve got a rock solid track record emerging world, don’t do it when you are really tired.
  3. In the best interest of the above, and your sanity, minimize the number of tilde keywords you have unmasked. I got all adventurous with one of my servers some years ago and there’s no good exit strategy. Sometimes it’s a pride point, other times, just pain.
  4. Don’t unmerge zlib. Just don’t, even if you are planning to put it right back. Pretty much nothing can run without it. Not portage, and not make, so you can’t get it back really. If you did, just copy libz.so (and symlinks) from another machine (probably of the same architecture).
  5. Also, don’t run eclean. It will break a lot of ebuilds and can’t even do that particularly well.

Getting setsy with portage

One of the main disadvantages of portage is the generally poor grouping of related packages. There are:

  • Package Categories (media-libs, dev-python, etc.) – These are pretty great, except when a package’s category changes and some ebuilds don’t pick up on that change. There is some way for portage people to redirect old ebuilds to new packages, but it has failed me more than once. Also, package categories don’t speak much to dependencies (not that they should). Portage/ebuild people decide on these, though the project maintainers might have some say.
  • Meta Packages (kde-meta) – Not many of these, but they seem to mostly be a dependency container. They are fine for installing, if a bit opaque, but they can be terrible for uninstalling. I’ve uninstalled old metas that left their obsolete and orphaned packages strewn about (kde 4.2 stuff). These are made by the project maintainers, I think.
  • “Profiles”(world, system) – Not a great name (maybe the wrong name?), but these aren’t as helpful and commonly used as they should be. Emerging world is definitely useful, but there could be a more granular operation between individual packages and ALL PACKAGES. These are generally automatically constructed for the user, though the user can do some manual editing.
Portage Screenshot

Oh KDE, you slay me.

Enter sets

Sets are basically like profiles, but the user gets a lot more control. They are groups of packages that can be reference like:

emerge --ask --update @my-set

You’ve got to admit that’s nicer than doing something like this.

Now when I said “Enter sets,” I meant… almost. Sets are only available in portage 2.2+. So the first step is to get that. Before that, I want to mention that it is technically still in alpha and a broken portage can make it hard to revert to a working portage. Nevertheless, so far it works fine for me and a lot of others have been using it since early 2009. In /etc/portage/package.unmask, add:

>=sys-apps/portage-2.2.0_alpha8

And in /etc/portage/package.keywords add:

sys-apps/portage ~*

Now, just emerge --ask portage and make sure it’s gonna pull in 2.2.

Your first set

Long story short, the format of the most basic user sets is just like the world file under /var/lib/portage/world. Just make a file with a list of packages, one per line, and put that file under /etc/portage/sets. For example, a set of scripting languages:


dev-lang/nodejs
dev-lang/php
=dev-lang/python-3.1.3
>=dev-lang/ruby-1.8.7_p249-r2
dev-lang/tcl

Now you can refer to that list of package like:

emerge --ask --update --deep @my-scripting-set

It may be prudent to prefix your sets so they don’t conflict with any other packages.

How to really clean up your system

By now you’ve probably seen the light, but I’m going to share one of my favorite uses so far to drive the point home. Say you’ve let your system go for a while, and you’ve accumulated some packages. Maybe you’ve switched from Gnome to KDE or maybe all the way to xmonad; regardless there is cruft to be removed. Here’s how you clean that stuff the Right Way:

  1. Update your gentoolkit and portage
  2. equery for some packages to remove and save the list:

    equery list kde-*/* > ~/kde_installed_packages_12122010

  3. Review the result and format properly. equery gives specific versions by defaults, so we’re just gonna throw ‘=’ in front of every line to make them valid package atoms. We’ll use sed:

    sed ':a;N;$!ba;s/\n/\n=/g' ~/my-kde-set

    You’ll have to manually add one more equal sign for the first line, but that should work.

  4. Review the result and move the file into place:

    mv ~/my-kde-set /etc/portage/sets/

  5. Depclean and unmerge:

    emerge --depclean --ask --verbose @my-kde-set

Ah, so fresh and so clean. You should move the set file out of the /etc/portage/sets directory now.

Conclusion

Sets fill a much-lamented (by me) gap in portage. They add organizational power without removing fine-grained control, without which Gentoo would not be Gentoo. My only concern is
Why did this take so long? Given that this is basically how ‘world’ has always worked and we’re well into version 2, we should have had this ages ago. Also, sets are really not that complex or tailored to package management, I wonder if archlinux or some other distro has solved this better. Of course, I’ve only scratched the surface, and there’s a lot more you can do with sets, it seems. For a good starting point, you can do a search on sets.conf.


P.S. The screenshot above was brought to you by ImageMagick:

import -window root ~/screenshot.png


Advertisements

Hit and Run: Windows Mobile Emergency

I had to call the police recently. A combination of laziness and problem urgency led to me dialing 911 on my Windows Mobile-powered cell phone.

When you dial 911, Windows mobile flips the FUCK out. Despite the Vibrate setting, my phone begins a very loud and very noticeable series of beeps as it enters “Emergency Mode”. In this mode, you cannot dial any numbers that are not emergency numbers, apparently. What programmer was sitting in front of Visual Studio, mashing away, thinking, “I’m saving lives here guys, with these beeps, these loud beeps.” Woe to the bank teller or kidnappee who tries to get wise. Here’s some wisdom: anything not Microsoft.

Sent from my iPhone


^ not really; do you think I’m made of money and data plans? Also, the thing that pushed me over the edge in writing this post is the fact that my phone has not rung since this. I just miss the call. Yes, I restarted it several times.

LESS and incron: CSS at its finest

less is, once again, more.

less is, once again, more.

Web development is full of challenges. That’s my nice way of saying writing CSS blows. CSS is powerful, but at the cost of being too fine grained and low level for easy development. It’s like the assembly of web design. Other developers are all-too-aware of the situation and have come up with a few solutions, including CSS frameworks, which reduce the amount of from-scratch code and provide a system (e.g., Blueprint or the 960 grid system), versus the freeform mess of raw CSS, and CSS extensions, like LESS, which is the topic of the day.

Act One: L-E-S-S spells bliss

If you aren’t using something like this yet, you might as well be punching yourself in the crotch every time you code.

I have also messed with Sass, which was not as “Syntactically Awesome” as LESS, and xCSS, which was overkill (but I might revisit it later). LESS is good because:

  • Any standard CSS file is a valid LESS file – easy to only use the features you need
  • Just as powerful as Sass, offering variables, functions, nesting, CSS-specialized math operations
  • Aptana CSS highlighting works great:
    1. Go: Window->Preferences
    2. General->Editors->File Associations
    3. Add file type: *.less
    4. Add editor: Aptana CSS Editor (right at the top)

I mean, look at this syntax:

@left_column_width: 300px;
@column_margin_width: 15px;

/** Palette **/
@light_blue: #d0dae3;
@pastel_blue: #7492ac;
@med_blue: #1e5d97;
@dark_blue: #0b3c68;

@light_orange: #f6b860;
@pastel_orange: #dfab62;
@med_orange: #e9951f;
@dark_orange: #a1630c;

/** Colors **/
@top_nav_color: @light_blue;
@top_nav_hover_color: @light_orange;
@header_color: @pastel_blue;

#header {
	clear:both;
	float:left;
	width:100%;
	border-bottom:1px solid @dark_blue - #111;
	background: @header_color;
	padding-bottom: 12px;
	margin-bottom: 7px;
	
	.page-title {
		float:left;
		clear:none;
		display:inline;
	}
}

/***** Two column layout a la   *********
****** http://matthewjamestaylor.com/blog/ultimate-2-column-left-menu-pixels.htm  *****/

/* column container */
.colmask {
	position:relative;
    clear:both;
    float:left;
    width:100%;			
	/*overflow:hidden;*/	
}

/* 2 column left menu settings */
.leftmenu {
    background:#fff;
	overflow:hidden;
	.colright {
	    float:left;
	    width:200%;
		position:relative;
		left: @left_column_width + (2 * @column_margin_width);
	    background:#fff;
	}
	
	.col1wrap {
	    float:right;
	    width:50%;
	    position:relative;
	    right: @left_column_width + (3 * @column_margin_width);
	    padding-bottom:1em;
	}
	
	.col1 {
	    margin:0 @column_margin_width 0 (@left_column_width + (4 * @column_margin_width));
	    position:relative;
	    right:100%;
	    /*overflow:hidden;*/
	}
	
	.col2 {
	    float:left;
	    width: @left_column_width ;
	    position:relative;
	    right: @left_column_width + @column_margin_width;
	}
}

Now you have an easily customizable two column layout and color scheme. Change your values in one place and they gracefully propagate. If you wanted to change the colors or column width before, you would have to change dozens of values. Really, stop what you’re doing, change your CSS file’s extension to .less, and become a happier person.

Act Two: Incron

So the only problem that I ran into is the bump in the workflow: compiling from LESS to CSS. This is where incron comes into play. Incron monitors files for changes and can trigger actions as specified by you with a cron-like syntax we can all love. I have a little Gentoo development box I use; I put incron on it and set it to run lessc whenever my LESS file changed. Just install/emerge incron, run incrontab -e and add one line:

	/path/to/less/files/mystyles.less IN_MODIFY lessc $@

Now you’ll have a file called my_styles.css and everything will be hunky dory. Of course this could easily be extended to do more powerful things with your styles, like move them into the right place or give them fancy names or version them or whatever. The potential here is also not limited to LESS, so consider it an investment. If this intrigues you, I think this tutorial should be all you need for now.

Well, web development is a big basket of ugly and this only addresses one aspect. There’s still cross-browser grossness and JavaScript debugging horror. But LESS helps. LESS helps.

SILT: bcrypt, IZZE, and burp edition

Delicious drank

Delicious drank

  • For all password storage, use bcrypt. Don’t use salted md5, definitely don’t use plain text. Also, don’t email users their passwords. The crypt() function in PHP actually has the blowfish algorithm alternative built in for versions >5.3.0, though you may want to set up the system libraries yourself, to allow for updates.
  • I recently invested in some IZZE sparkling juice. It’s pretty much carbonated juice cocktails. There are a few flavors and I’ve tried the Pomegranate, Clementine, and Grapefruit. Cranberry’s cranberry, Clementine is ok, Pomegranate could taste more like pomegranate, but is still good, and Grapefruit is probably the best. Grapefruit’s a little too sweet, so I like to add some tonic water. For drinkers, these would probably be great mixers. I get mine on Amazon, where they go on sale every once in a while for like $15 for 24.
  • Speaking of security and carbonated things, you’ve got to check out Burp Suite. It is an amazing application for security testing web applications. It automatically fuzzes apps. For the click-lazy, fuzzing is just providing wildly invalid data where only a computer could think to put it. As soon as I develop something security-sensitive, ya’ll know I’m buying this.

SILT: Stuff I Learned Today

This is my dad wearing a pair of shades I found.

This is my dad wearing a pair of shades I found.

This is the first in an indefinite series of catch-all blogposts. Now that school is up and my schedule is more regular I think I can make a few more minutes a day to log some findings and post some links. Also, I’m thinking that by presenting a more innocuous task (a short, general post, as opposed to a long, targeted one), I might find myself sowing the seeds of expanded posts.

Also, sometimes I feel silly calling up friends and telling them each individually about cool junk when I know they’re all subscribed to this baby right here. Content will range from factoids to news to mini-rants to Linux and beyond. So:

  • Peep Show Season 6 has started. I might need to cache up the whole season before I start, it’s such dark goodness. 9.5/10 on imdb with 5,200+ votes? Intense.
  • I found out a way for a Linux machine to dynamically get a hostname on a Microsoft Active Directory network that isn’t set up to update hostnames via DHCP. This was ridiculously hard and I strongly suggest you contact me if you ever run into this issue. It involves kerberos and this one-off script.
  • I’m watching Kate Humble’s 4-part series of Middle Eastern travel, The Frankincense Trail. It’s from the BBC and it’s not too bad. It probably is a bit too frankincense-centric to be honest, what with her hauling her own little load of frankincense everywhere and asking everyone whether their people use or used frankincense. The most interesting tidbit I picked up is that apparently some parts if not all of Israel enforce some crazy Shabbat rules. For instance, you can’t use (technically be directly involved in the use of) anything electrical. You can ride an elevator, but you can’t press the buttons (it stops on all floors). You can open a fridge and grab something, but you have to tape the light sensor down beforehand. All this because it’s the ‘day of rest’. I’m wondering how universally this stuff is implemented.
  • Last, but certainly not least, Oyama is back up at the makuro.org address. My $30 Time Warner lets me upload at like 300kb/s so please be courteous and only max out my connection at night or during the workday. Also, I’ll know who my true friends are based on who logs in first (only my true friends use RSS and FTP).

Well, here’s hoping that wasn’t too painful, because I’m planning on learning a lot of stuff and posting about it. And then, this series of blog posts, like its namesake (silt), will provide me and my offspring a fertile farmland on which to raise agricultural goods.

A quick trick for the DN-S1200

Edit: Or you could just click the effect style knob (the one used to scroll through songs, as well). I thought I might have done it without the brake button. Ah well.

While researching the Denon S1200 turntables, I recall reading a review or two that complained about the interaction between the built-in effects and the scratch functionality. Because the jog wheel is used to both scratch and adjust the wet/dry of the effect, people simply couldn’t scratch with an effect active. I think I’ve found a workaround.

First, activate the effect and adjust it to the desired level. Then, double-tap the BRAKE button at the bottom. This enters then exits the brake activation menu. (You can actually use the DUMP and REVERSE buttons, too, but those interfere with playback.) Now, you’ve dropped back into simple playback mode and you can scratch to your heart’s content with an effect active. To disable the effect, just double-tap the effect button.

I like to add some flanger to beef up and texturize my samples. Filters also work well for some variety. Echo/Loop doesn’t really do much because applying pressure to the disc stops all sound and the echos seem to only be generated when the track is playing. Anyway, that’s two more effects than I had before, so I’m happy.

Music Management

Collections are pretty fun. Most people probably tend to accumulate things, and the smarter ones tend to realize that organization is the only way that one’s collection will ever see effective use.

Kid Loco on KDE4/Dolphin

Kid Loco on KDE4/Dolphin

DJing relies pretty heavily on having and knowing a lot of music. It’s also probably the coolest collection-based hobby/profession. Stamp and rock collections just don’t cut it. It’s easy to find examples of organization taken too far, but luckily my hobby supports my misprioritization, and I have a very organized MP3 collection. So, here’s how I do it.

  1. torrent or slsk or audiograbber (w/ lame) my music
  2. Use MusicBrainz Picard to complete incomplete tags and cluster/manually tag most music. It’s a little bit different, but it’s ridiculuously automated and very handy for letting you know when you have an incomplete album, etc. Before this, I used PsychicMP3 and discogs pages.

    MusicBrainz Picard Automated MP3 Tagger on Windows

    MusicBrainz Picard Automated MP3 Tagger on Windows

  3. Optional: Automatically record most of the bpm info into the file with MixMeister BPM analyzer. Even if you’re just making a playlist for your workout, knowing the speed of the tracks can help you create a much more cohesive and flowing mix.
  4. I tag anything rare or unrecognized by MusicBrainz with Mp3Tag at this point. Also, MixMeister’s not so good on swing rhythms and some stranger time signatures, or bpms less than 80/greater than 160, so I check them in Mp3Tag with a javascript bpm tapper.
  5. For when I feel like being crazy, I’ll run MP3Gain or something. MP3Gain can automatically normalize your music so you don’t have super loud or super soft tracks. If you don’t know what you’re doing you can introduce distortion, though. Usually, if the track sounds ok, I’ll leave well enough alone.
  6. I check for untagged/low quality files that got through before I started doing all this with MP3 Check

I stick to MP3, 192kbps or higher, VBR or CBR. I like to keep the sample rate at 44100hz, as that’s what the DN-S1200s support. I get FLAC albums (when I can find them), for my real faves, but of course keep the MP3s for portability reasons.

As for folder structure, I’m a sucker for Artist/Album (Year)/Tracks. A lot of renaming and tagging software will move stuff around for you, so yay. Oh, and I have to say that one of the most consistently frustrating things about tagging music is having to pick a genre for a song/album. I wish I could just leave it blank, but I’m a completionist.

So, is this waaay too much work? Did you note that all of these tools are Windows-based (except for Picard!)? Luckily, I store my MP3s on my server and grab them with samba, but if Linux had these tools, you know I’d grab that ebuild. If I missed them, let me know. Also, Amarok2 not working on amd64 gentoo is ridiculous. Not only that, but when I got it working, it blew chunks compared to amarok 1. Too much focus on peripheral media, not enough collection- and tag-based power.