The Linux Page

Pages with category Development

  • I have a table with a few columns, two of which are integers, one of which can be NULL in which case the other integer is to be used in my query.

    CREATE TABLE my_table (col1 INTEGER NOT NULL, col2 INTEGER);

    If `col2` is NULL, then use `col1`. As is, there is how my query looks like:

    SELECT MIN(IF(col2, col2, col1)) AS smallest FROM my_table LIMIT 1;

    In other words, I need to get the row with the smallest integer, but if one column is NULL, I want to use the other column value.

    On a very small sample, the query is still very fast, but the real version is not unlikely to have thousands ...

  • Today I wasted another hour or so in trying to get samba to work for one of my Windows computer so I could connect to one of my Linux computer. I knew that the installation was correct since I could log in with another computer/user that had worked for a long time. So... why would this one fail?

    Two things, for of all, I could see NOTHING happening in the logs. Really wondering why the default is to log close to nothing with such a non-secure piece of software, but that's a different question. I added the following to actually get about enough logs to understand what was happening:

    log ...
  • Today I ran in a little bit of a problem with an new Cassandra node installation.

    After the node was created, I ran nodetool and got this:

     $ bin/nodetool status
    Datacenter: dc1
    ===============
    Status=Up/Down
    |/ State=Normal/Leaving/Joining/Moving
    --  Address    Load       Tokens       Owns (effective)  Host ID   Rack
    UN  127.0.0.1  219.83 KiB 256          0.0%              73bd8721  rack1

    It took me a little while to find out that the problem was the IP address. Although it clearly says 127.0.0.1 here, the cassandra.yaml configuration file had localhost.

    I edited the ...

  • Once in a while I check how the compilers are behaving in such and such situations to make sure that when I wrote code it gets properly optimized. Today I was surprised as I tried to put a break point of a variable and it looked like the compiler wasn't using it. Indeed, the optimizer 100% removed the variable from the final code. Quite interesting since trying to reverse engineer this assembly language would probably end up using a goto statement... (ouch!)

    The code goes more or less like this:

    [toc hidden:1]
  • Today I was trying to create a table in a post and just could not get the cell padding I wanted. Without the padding the data is all cramped together which did not look the way I wanted (see Alexis Wilke Accounts.)

    I knew I had the following entry in my CSS but did not think it was stronger than the table cellpadding and cellspacing specifications because I thought it worked for me before!

    * {
      margin: 0;
      padding: 0;
    }

    I was wrong, that definition applies to the td with a greater constrained. So I had to add another entry. I solved the problem using a td definition like this:

    
    
  • I had a problem with jQuery and was wondering what could be wrong. Looking around for a solution, it was clear that Internet Explorer is the problem. Not the other way around (As usual.) The thing is that the function works, just not in realtime.

    So... I have a Terms and Conditions flag, when you click it, I want to enable the Submit button in the form (by default the button is disabled.)

    So I have a function something like this:

    var valid = function check_valid() {
      // compute valid
      var valid = ...;
      // assume valid === true if button should be enabled
      ...
  • I use Drupal for most of my sites. I use it in many different ways and it has been working real good for me.

    On one of the sites, I use the ThemeKey module to select a different theme once you are logged in. This means, when I want to switch themes, that one theme selected for logged in users sticks, whether you disable it or not, it remains selected by the system.

    And?

    Well... one thing sticks from themes, their .info file. You just cannot refresh the cache properly unless you disable the theme, then re-enable it. (By the way, when disabled, don't go to the Blocks administration screen ...

  • Often, when one writes a game, one wants a specific resolution to make sure that the game works as expected. Zoomed out textures may not look as nice and the speed could be affected too (drawing 1280x1024 pixels instead of 640x480 is more than 4x higher and all video boards won't be as fast as required in this case). Under MS-Windows you can ask the system to change resolution (size & depth) with a call to ChangeDisplaySettings().

  • Today I wanted to check whether a table existed in a MS-Access database from a macro define in a MS-Access module.

    The test opens the specified database (databaseName) and from that object checks wether a table definition exists (name). I wonder whether there would be a better way to go through the list of items and just know whether an item with that name exists or not instead of generating an error (because the underlaying system will anyway search that list of items for the name, although it may be faster this way in visual basic.)

    There is the function I wrote (sample usage: if ...

  • MS-Access has forms, but no real means to know whether a form exists. It looks like you could go through the list of forms (Forms.item(i)) but I'm not too sure that would work in all circumstances.

    Instead, I used code I found on another site which runs a system command to determine whether a form is currently attached to a window (has a state other than zero.)

    The code looks like this:

    IsLoaded = False
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
        If Forms(strFormName).CurrentView <> 0 Then
            IsLoaded = True
        End If
    End If

    The first ...

Syndicate content

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.

     

   

Terms of Site Index

Find the page/content you are looking for with our index.

  • EPROM
  • PayPal

    An online credit card processor that anyone, including individuals, can use to get paid. Often viewed as expensive though.

  • backup
  • search
  • type