The gold linker
The gold linker is a new ELF included in the binutils package since version 2.19. It was implemented by Ian Lance Taylor so I leave the technical introduction to him. And of course Diego wrote some nice things about it.
So what we can gain from its usage compared to the bfd linker:
1. faster and more efficient linking (5 times have been estimated)
2. Detection of underlinking. I won't go into details, but read this post post for more details
So if you like to try it, use following little hack. But BE WARNED, things are likely to get broken, so don't use this on system packages and the kernel.
_gold() {
pushd /usr/bin
ln -sf x86_64-pc-linux-gnu-ld.${1} ld
ln -sf /usr/x86_64-pc-linux-gnu/bin/ld.${1} x86_64-pc-linux-gnu-ld
cd /usr/x86_64-pc-linux-gnu/bin/
ln -sf /usr/x86_64-pc-linux-gnu/binutils-bin/2*/ld.${1} ld
popd
}
setgold() {
_gold gold
}
unsetgold() {
_gold bfd
}
Pushing static routes with ISC Bind
Pushing static routes to your dhcp clients with pfsense was tricky because you have to specify the network and router informations as the raw hex values. Accomplishing the same task with the ISC DHCP server is easier. First of all, we have to declare the dhcp option in the global scope to the server:
option rfc3442-classless-static-routes code 121 = array of integer 8; option ms-classless-static-routes code 249 = array of integer 8;
The second line is for Windows clients, because MS decided to use the dhcp option 249 instead of the existing 121. The next step is to declare these options in our subnet definition:
subnet 192.168.1.0 netmask 255.255.255.0 {
... other options ....
option rfc3442-classless-static-routes 24, 192, 168, 123, 10, 10, 10, 1, 0, 192, 168, 1, 2;
option ms-classless-static-routes 24, 192, 168, 123, 10, 10, 10, 1, 0, 192, 168, 1, 2;
}The format of the options is:
<netmask>, <network-byte1>, <network-byte2>, <network-byte3>, <router-byte1>, <router-byte2>, <router-byte3>
where bytes with the value 0 are omitted. Again, you should include the default route in the options because dhcp clients are allowed to ignore the option routers x.x.x.x option. So, the line option rfc3442-classless-static-routes 24, 192, 168, 123, 10, 10, 10, 1, 0, 192, 168, 1, 2 specifies the following routing informations:
24, 192, 168, 123, 10, 10, 10, 1: 192.168.123.0/24 via 10.10.10.1 0, 192, 168, 1, 2: 0.0.0.0 via 192.168.1.2 (default route)
SVN Commit Notifications via Twitter
The commit messages of the last-hope Overlay are now published via Twitter. Follow @LastHopeOverlay to stay in touch (or use the rss feed).
The post-commit hook is a simple python script using the python-twitter module:
#!/usr/bin/python
import twitter
import sys
def post_update(message):
api = twitter.Api(consumer_key='CONSUMER_KEY', consumer_secret='CONSUMER_SECRET', access_token_key='ACCESS_TOKEN', access_token_secret='ACCESS_SECRET')
api.VerifyCredentials()
update = message
if len(update) > 140:
update = "%s..." % update[:137]
api.PostUpdate(update)
if __name__ == "__main__" and len(sys.argv) > 1:
post_update(' '.join(sys.argv[1:]))
Since twitter only supports OAuth for authentication and authorization, you have to register a new application at https://dev.twitter.com/apps. Assign the read/write access level to the application and create a new access token for your account. Fill the values in the code and run it: python twitter-update.py "This is an example message". Install it as a post-commit hook and all commit message are now send to twitter.
Improve Django ORM performance on Foreign Keys
If you use Foreign Keys on a model in Django, you might not be aware of performance issues until it hits you. Navigating through ForeignKey relationships in your code/templates are very easy, but creates a db query every time.
Lets look at this problem with a simple model:
class Category(models.Model):
name = models.CharField(max_length=255)
class Article(models.Model):
title = models.CharField(max_length=255)
content = models.TextField()
category = models.ForeignKey(Category)
created_by = models.ForeignKey(User, related_name='+')
modified_by = models.ForeignKey(User, related_name='+', blank=True, null=True)
For a list of articles you could write something like this:
for article in Article.objects.all():
print "%s by %s in %s" % (article.title, article.modified_by or article.created_by, article.category.name)
Run the code and look at the generated queries (either in the django development server output or, a litte bit prettier, in the SQL tab of the Django Debug Toolbar. With 3 Article objects, this will create 7 SQL queries to your database:
- One for the list of article objects
- One for the
modified_byfield on each object - One for the
created_byfield on each object - One for the
categoryfield on each object
To work around this issue, you can call select_related() on the Manager object of the Article class. This will combine all referenced objects into one query, which is usually a lot faster! Have a look into the documentation for a list of parameters.
Samsung Q330 Hotkeys
Emerge app-laptop/samsung-tools (more precise app-laptop/easy-slow-down-manager) for the samsung-backlight module, or try the SAMSUNG_LAPTOP option in the staging drivers area.
Put
{
/* Samsung Q330 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "Q330"),
},
.callback = atkbd_setup_forced_release,
.driver_data = atkbd_samsung_forced_release_keys,
}
in the /usr/src/linux/drivers/input/keyboard/atkbd.c file around line 1675. Recompile and reboot.
Use
setkeycodes e008 225 setkeycodes e009 224
to make this keys known.
