Say I have a select SELECT DISTINCT id, customer_id, domain FROM config WHERE type = ‘foo’; which returns some records. How can I do an insert for reach row in the result set like INSERT INTO config (id, customer_id, domain) VALUES (@id, @customer_id, ‘www.example.com’); where @id and @customer_id are the fields of the row in [...]

{ 0 comments }

I’ve done threads in Java, but I’m a complete noob to threads in C. My first question, after googling some, is: Which thread library do I use? Does it matter? It seems I have thread.h and pthread.h to choose from. OS is, and will be, Linux. More specifically, it’s Ubuntu at the moment and will [...]

{ 0 comments }

matching one character in mysql in place of %

May 17, 2012

In the following SQL select * from X where Y like “%s”; the ‘%’ will match any characters before an s. The % can be ‘x’, ‘xx’, ‘xrf’, etc. Is there any symbol that will only match one character, like: select * from X where Y like “?s” where ? will match only one character [...]

Read the full article →

How to append html to with jQuery

May 16, 2012

I am trying to append a Facebook open graph tag (based on dynamically generated content on the page) to the head of my html. $(document).ready(function(){ var stat = $(‘#random-message’).text(); stat = jQuery.trim(stat);//set facebook Open Graph description $(‘head’).append(‘<meta property=”og:description” content=”‘+stat+’”/>’); }); this by itself is working fine. js fiddle When I combine it with a dynamically [...]

Read the full article →

At what point does MySQL INNODB fine tuning become a requirement?

May 16, 2012

I had a look at this: http://www.mysqlperformanceblog.com/2009/01/12/should-you-move-from-myisam-to-innodb/ and: http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ These answer a lot of my questions regarding INNODB vs MyISAM. There is no doubt in my mind that INNODB is the way I should go. However, I am working on my own and for development I have created a LAMP (ubuntu 10.10 x64) VM server. [...]

Read the full article →

How does the github UI navigate directories without postbacks?

May 15, 2012

When navigating through my repo directories on github.com, I noticed that it uses cool javascript effects to switch between directory views without ever causing a postback, and yet the url changes nice and RESTfully: http://../tree/master/dir7 -> http://../tree/master/dir7/dir4. Whenever I have to keep track of navigation with javascript, I’ve always had to resort to hash arguments [...]

Read the full article →

Multidimensional Array PHP Implode

May 14, 2012

In terms of my data structure, I have an array of communications, with each communications_id itself containing three pieces of information: id, score, and content. I want to implode this array in order to get a comma separated list of ids, how do I do this? Asked by Peter You need to make an array [...]

Read the full article →

How does Amazon RDS backup/snapshot actually work?

May 14, 2012

I am an Amazon RDS customer and am experiencing daily amazon RDS write latency spikes, corresponding roughly to the backup window. I will also see spikes at the end of a snapshot (case in point: running a snapshot takes appx 1 hour, and in the final 5 minutes, write latency spikes). I am running a [...]

Read the full article →

Rewriting a recursive function in perl so that it can be used in list context

May 14, 2012

Consider the binary tree developed in Moose::Cookbook::Basics::Recipe3 To retrieve all nodes in preorder, I could add the following subroutine to the BinaryTree package sub pre_order { my ($self,$aref) = @_; push @$aref, $self->node; pre_order($self->left,$aref) if $self->has_left; pre_order($self->right,$aref) if $self->has_right; } The sub would have to be used like this: my $btree = BinaryTree->new; #add some [...]

Read the full article →

Cannot overwrite Symbolic Link RedHat Linux

May 14, 2012

I have created a symbolic link: sudo ln -s /some/dir new_dir Now I want to overwrite the symbolic link to point to a new location and it will not overwrite. I have tried: sudo ln -f -s /other/dir new_dir I can always sudo rm new_dir, but I would rather have it overwrite accordingly if possible. [...]

Read the full article →