I suppose I have to do this sooner or later. Here's a track I recorded.
Gear:
Fender Squier 5 string Jazz Bass, defretted by yours truly.
Korg PXR4
Audacity for some post-recording cleanup.
I made this whole thing up on the fly; there were three tracks:
1) the "drum" part: basically a muted slap of the fingerboard
2) single notes
3) "7" chords (1,3,b7)
Random bass
Read more...
Saturday, February 27, 2010
Random bass
Posted by Bradley at 10:17 AM 0 comments
Labels: bass
Friday, February 26, 2010
Numeric Formatting in Django
You might have seen my previous post lamenting the weirdnesses around number formatting in python. This spills over into Django; if you have DecimalFields in your models (especially if you are using the ModelForm object to create your forms.
The previous "format Decimal object as a string that any 10-year-old would expect" method is:
def dec_string(dec):(I added the isinstance() bit to protect me from myself =)
if isinstance(dec, Decimal):
if dec:
if dec.normalize().as_tuple().exponent > 0:
return "%d"%dec
else:
return "%s"%dec.normalize()
else:
return 0
else:
return dec
Since we know how to format this, all that remains to be done is to create a widget that automatically formats DecimalFields correctly.
class DecimalInput(TextInput):And then just use that in your form:
def render(self, name, value, attrs=None):
value = dec_string(value)
return super(DecimalInput, self).render(name, value, attrs)
class EnergyForm(ModelForm):
kwh = DecimalField(widget=DecimalInput(attrs={'size':'6'}))
There is more to the ModelForm, but that's what the docs are for, right? Read more...
Posted by Bradley at 1:11 PM 0 comments
Labels: django, forms, math is hard, python
Numeric Formatting in Python
Sometimes I hate Python. Here's the difference between Perl and Python: Perl accepts, even embraces the fact that language is messy. Python sometimes gets this wrong.
Here are some samples of dealing with formatting numbers:
from decimal import DecimalHuzzah, it does the right thing!
>>> f= Decimal('1200.1')
>>> "%s"%f.normalize()
'1200.1'
Doh! But clearly, removing the normalize() will fix things, right?
>>> f= Decimal('1200')
>>> "%s"%f.normalize()
'1.2E+3'
>>> "%s"%fYee-haw! Now we're cooking!
'1200'
>>> f= Decimal('1200.100')Hm, users don't want the trailing zeroes. The only thing that I can think to do is use a regular expression, and now I have two problems.
>>> "%s"%f
'1200.100'
But wait! If the number doesn't have anything after the decimal, then we do one, and if it does, we do the other!
def dec_string(dec):And that seems to be working. Note that the final version uses "%d"%dec, rather than %s, since we want to make sure and truncate past the decimal.
if dec:
if dec.normalize().as_tuple().exponent > 0:
return "%d"%dec
else:
return "%s"%dec.normalize()
else:
return 0
Update: check out my post about integrating it with Django forms to make it seamless. Read more...
Posted by Bradley at 7:05 AM 0 comments
Labels: math is hard, python
Thursday, February 25, 2010
Nginx for static content
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|html|htm)$ {
root /static;
}
All of the dynamic stuff is happening in Django running under Apache using ModWsgi. Since this is a fairly heavy stack (Apache is very robust and featureful, but is also somewhat romanesque).
So that we're not using a 10 lb sledgehammer to do finish nails (remind me to tell you about the time that I saw a full-bird Colonel drop a sledgehammer on a Lt. Colonel's foot!), we basically tell Nginx to serve up anything ending in "jpg", "xls", "pdf", etc. from the static directory, without talking to Apache. Read more...
Posted by Bradley at 9:50 AM 0 comments
Labels: apache, internet scale computing, nginx, scalability
Wednesday, February 24, 2010
Blacklist in CyanogenMod
If you are running CyanogenMod on your Android device, and are surprised that some people seem to not be able to call you (half a ring, then hangup), you probably accidentally blacklisted that user.
My hope was that there was some simple method to clear this blacklist (which essentially "killfile"s phone numbers). Either I misunderstood the user interface, or there was something desperately broken, but I could not figure out a way to clear the blacklist. So I went digging in the source (yeah for open source!).
Turns out there is a file called blacklist.dat that stores these numbers, so here's my brute force solution for clearing the phone black list:
- open terminal
- su
- rm /data/data/com.android.phone/files/blacklist.dat
- reboot
And now, your wife is able to call you again, contributing to marital harmony FTW.
PS- no, I didn't tell you that you need a rooted phone, since you don't have this issue unless your phone is rooted. Read more...
Posted by Bradley at 7:26 AM 0 comments
Labels: Android
Tuesday, February 23, 2010
Ribbecke Halfling For Sale
It will be available on Bass Northwest's web site (http://bassnw.com/) by tomorrow. You can also contact me if you are interested in purchasing.
I realized as I was getting ready to write this that I never did a full blown blog post about the Halfling (one under construction one was all). Shame on me! This is one of the most unique bass guitars that I've ever seen; the tone, workmanship, and looks on this guitar rival any boutique, high-end guitar/bass. To make up for not doing a full post, here are some pictures of this very, very beautiful guitar.
Read more...
Posted by Bradley at 3:08 PM 1 comments
Sunday, February 21, 2010
New business card?
I'm looking for feedback. I'm thinking of making this my new "personal" business card.
Questions for the gallery:
- What do you think of the tagline?
- What do you think about the flourishes?
- What do you think about the domain name (consciou.us)?
-- Read more...
Posted by Bradley at 2:23 PM 5 comments
Labels: business card
Thursday, February 18, 2010
Purging a hard drive in Linux
There is a lot of information available out there on purging hard drives; this is the lower-security, quicker way to do it.
dd bs=1M if=/dev/zero of=/hard/drive/device
This will overwrite the drive with zeroes.
for more security, but a longer process:
dd bs=1M if=/dev/urandom of=/hard/drive/device
Which will overwrite the drive with random data.
Read more...
Posted by Bradley at 11:05 PM 0 comments
Wednesday, February 17, 2010
Haitz's Law, and what it means
What it means is this: you will be using LED based lighting within the next few years.
Haitz's law on Wikipedia. Briefly, LEDs' cost per lumen falls by a factor of 10 every 10 years, and the output in a particular format rises by a factor of 20.
In other words, that LED bulb that now costs $60 will be:
- $12 in a few short years,
- Will have a lifespan measured in tens of thousands of hours (rather than 1000 hours for the typical incandescent)
- Will be 2-3 times more efficient in terms of energy usage than a comparable incandescent.
Posted by Bradley at 2:46 PM 0 comments
Tuesday, February 16, 2010
Want. Now.
Well, the title is Random Desiderata, after all.
I need one of these immediately: Millennium Falcon.
(from Gizmodo)
My faith in mankind has been restored.
Read more...
Posted by Bradley at 6:22 PM 0 comments
Labels: desiderata