Showing entries 11 to 19
« 10 Newer Entries
Displaying posts with tag: hacks (reset)
Adding a value to enum Column - A Dirty Hack

It is the first time I am going to write something serious after registering this domain. Probably I was too lazy to blog or I was working hard that I had no time to write blogs.

Any way I have decided to break the silence

Today I came across a problem where I had to add a new value to an enum column in a table with a few million rows. The traditional method of getting that done will take ages to finish and I could not afford to have a such a long window. Fortunately for me I was dealing with a MyISAM table and I had a dirty trick in mind ]:< .

I will list out a small example showing how I did it:

Suppose my table is

create table a( id int,
choice enum('agree','disagree')
)Engine=MyISAM

and I want add a new choice ‘ Don’t care’ what I will do is , I will create a new table …

[Read more]
A quick usability hack with partitioning

A few days ago I was describing a common grievance when using partitions.
When you care at a table, like the following

CREATE TABLE t1 ( d DATE ) 
PARTITION by range (to_days(d))
(
partition p001 VALUES LESS THAN (to_days('2001-01-01'))
, partition p002 VALUES LESS THAN (to_days('2001-02-01'))
, partition p003 VALUES LESS THAN (to_days('2001-03-01'))
);


Then you have the problem of finding out the original values. SHOW CREATE TABLE doesn't help.
show create table t1\G
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`d` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (to_days(d)) (PARTITION p001 VALUES LESS THAN (730851) ENGINE = MyISAM, PARTITION p002 VALUES LESS THAN (730882) ENGINE = MyISAM, PARTITION p003 VALUES LESS …

[Read more]
Presence, my bot tracks my phone

One of the projects I completed last week was the upgrade of the house phone system to the latest version of Trixbox (aka asterisk, aka defunct Asterisk@Home, more to come on that later).

I rarely answer my home phone line though. To even get to my extension you have to know what it is ahead of time, since the message you get when you dial my home phone line is "go away". If you know my extension though you can still get to me, which most likely means you will get my voicemail. All voicemail from the house line is sent to me as email, unlike my cell phone where it sits and rots.

If you can navigate my home phone system, I probably want to hear from you. With the upgrade I wanted my phone system to push data to me. To do this I wanted to integrate it into Laslow (and yes this is the next generation of Wolsal for those who remember it).

Laslow is an AIM bot that I run.

Why AIM? When my …

[Read more]
WRT54G Adventures

While traveling this last week I read up on converting a Linksys WRT54G to better firmwares. I just so happen to have one of these and while it works, it has several limitations that I would like to do away with :)

Getting home on Saturday means that when I get up on Sunday this is one of the first things on the list to do!

Take option one and risk my working router? No, I go to Best Buy to pick up a second WRT54G. While I may already have one, I did not want to chance turning my current one into a brick.

The one I picked up at Best Buy of course turns out to be a version 5, which is a nightmare to upgrade and will soon be returned. Linksys decided to change the hardware they use in their routers recently. The version 5 box has less memory and Cisco has …

[Read more]
Sudoku solver

Sudoku solver

There are probably tons of these already available, but here is a quick sudoku solver (in Perl):

#! /usr/bin/perl

# Example:
#
# echo $'      2  \n  1 9  4 \n 2 1 5  9\n3     6  \n  68 41 5\n  427 8  \n   51    \n     7 3 \n79    5  '| perl sudoku-solve.pl
#

use strict;
use warnings;

my $s = read_sudoku();

my $res= solve($s);

if($res) {
  print_sudoku($res);
  print "Got it!\n";
} else {
  print "Failed :-(\n";
}

exit 0;

sub solve {
  my ($s)= @_;

  my $res= try_solve($s);

  return $s if $res eq 'SOLVED';

  return undef if $res eq 'FAIL';

  # Make a guess, backtracking if we were wrong.
  # Try to find some field where there are only two possibilities.
  my ($a, $b);

 OUTER:
  for my $i (0..8) {
  INNER:
    for my $j (0..8) {
      next INNER if keys(%{$s->[$i][$j]}) == 1;
      if(keys(%{$s->[$i][$j]}) == 2) {
        ($a,$b)= ($i,$j);
        last OUTER;
      } elsif(!defined($a)) {
        ($a,$b)= ($i,$j);
      } …
[Read more]
Random Information for the Morning on Thread Creation

My dual opteron which has gobs (more then 2gigs) of memory will not let a single process spawn more then 12,000 threads at any time.

Well, somewhere between 12,000 and 13,000 threads things go haywire. I had a program I put together yesterday break because it was let loose with thread creation. So last night I wrote a little loop around an application just to see where consistent thread creation could occur (each thread did nothing more then maybe sleep for a second (it had a one in seven chance of the sleep event occurring)).

I am sure there is a system limit I am ignoring, but I wanted to see what the practical numbers where in this case.

Completely random and probably worthless information :)

Its crazy to generate this many threads in the first place. I saw Nusphere once do this with Gemni to prove a point about concurrency, but it didn't prove much of a point for me since I thought …

[Read more]
Example of how to not write a "make test"

[brian@zim tdb]$ make test
mkdir -p /usr/local/bin
mkdir -p /usr/local/include
mkdir -p /usr/local/lib
mkdir -p /usr/local/lib/pkgconfig
mkdir: cannot create directory `/usr/local/lib/pkgconfig': Permission denied
make: *** [install] Error 1

Now why do I need to install your software just to run the test program?

The answer is that I should not have too.

I think I will go play Settlers now...

And yes, I am working on porting a storage engine this evening that I want to toy with.

Why is this?

Because I have a huge stack of expense reports I need to get done for mysql before I leave on Monday for a trip, and I will do almost anything I can to avoid doing my expense reports.

Seattle MySQL Meetup

Just as a reminder, there is a MySQL Seattle Meetup on Monday at the Elysian. People show up at 7:00.

More Information is here:
http://mysql.meetup.com/31/events/4796298/

I believe I should have some O'Reilly books on hand to give out.

Topics have included: MySQL, MySQL, favorite science fiction shows, Asterisk, and the ever popular "how many channels of TV are you recording on your MyTH system"

distcc, building MySQL, bad ideas

After a little bit of playing around I got distcc to fully work when compiling MySQL today. None of this really had to do anything with MySQL in particular, and really had more to do with just getting all of the permissions setup correctly for distcc. My account on the build machine now has the following information:

export CCACHE_PREFIX=distcc
export MYSQL_BUILD_PREFIX=/home/brian/mysql-builds/example
export MTR_BUILD_THREAD=42
export DISTCC_HOSTS="localhost hell heaven purgatory"

The first tells ccache to use distcc, the second is to tell the MySQL BUILD/ scripts to always build binaries that install with a particular build directory, the third tells mysql_test to restrict itself to a certain set of ports, and the final variable just tells distcc where to send code to be compiled.

All in all it is pretty slick, though one big annoyance is the lack of ability to speed up mysql_test at …

[Read more]
Showing entries 11 to 19
« 10 Newer Entries