Search Results

Search found 40 results on 2 pages for 'nickf'.

Page 1/2 | 1 2  | Next Page >

  • Deeply nested subqueries for traversing trees in MySQL

    - by nickf
    I have a table in my database where I store a tree structure using the hybrid Nested Set (MPTT) model (the one which has lft and rght values) and the Adjacency List model (storing parent_id on each node). my_table (id, parent_id, lft, rght, alias) This question doesn't relate to any of the MPTT aspects of the tree but I thought I'd leave it in in case anyone had a good idea about how to leverage that. I want to convert a path of aliases to a specific node. For example: "users.admins.nickf" would find the node with alias "nickf" which is a child of one with alias "admins" which is a child of "users" which is at the root. There is a unique index on (parent_id, alias). I started out by writing the function so it would split the path to its parts, then query the database one by one: SELECT `id` FROM `my_table` WHERE `parent_id` IS NULL AND `alias` = 'users';-- 1 SELECT `id` FROM `my_table` WHERE `parent_id` = 1 AND `alias` = 'admins'; -- 8 SELECT `id` FROM `my_table` WHERE `parent_id` = 8 AND `alias` = 'nickf'; -- 37 But then I realised I could do it with a single query, using a variable amount of nesting: SELECT `id` FROM `my_table` WHERE `parent_id` = ( SELECT `id` FROM `my_table` WHERE `parent_id` = ( SELECT `id` FROM `my_table` WHERE `parent_id` IS NULL AND `alias` = 'users' ) AND `alias` = 'admins' ) AND `alias` = 'nickf'; Since the number of sub-queries is dependent on the number of steps in the path, am I going to run into issues with having too many subqueries? (If there even is such a thing) Are there any better/smarter ways to perform this query?

    Read the article

  • No HDMI sound output on Thinkpad X1

    - by nickf
    I'm having problems getting my sound to output via HDMI to my TV. When I go to Sound Settings, the HDMI device does not appear. ~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: CONEXANT Analog [CONEXANT Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 I don't know if the video information is helpful, but anyway: ~$ sudo lshw -C video *-display description: VGA compatible controller product: 2nd Generation Core Processor Family Integrated Graphics Controller vendor: Intel Corporation physical id: 2 bus info: pci@0000:00:02.0 version: 09 width: 64 bits clock: 33MHz capabilities: msi pm vga_controller bus_master cap_list rom configuration: driver=i915 latency=0 resources: irq:46 memory:d0000000-d03fffff memory:c0000000-cfffffff ioport:5000(size=64) Any suggestions for me?

    Read the article

  • Upgrading Ubuntu 9.04 to 9.10 when Update Manager doesn't let you

    - by nickf
    I've been trying to upgrade my installation of Ubuntu 9.04 to 9.10, but all of the instructions I've found haven't been helping. They mostly say to run the update manager and it'll tell you that there's a new distribution ready. Well, mine doesn't say that. Things I've run or checked: update-manager -d says: Your system is up-to-date The package information was last updated less than one hour ago. I've set it to get all new distributions, not just LTS $ cat /etc/update-manager/release-upgrades [DEFAULT] # default prompting behavior, valid options: # never - never prompt for a new distribution version # normal - prompt if a new version of the distribution is available # lts - prompt only if a LTS version of the distribution is available Prompt=normal I'm definitely running 9.04 $ lsb_release -r Distributor ID: Ubuntu Description: Ubuntu 9.04 Release: 9.04 Codename: jaunty Even running the release upgrade from console doesn't help: $ sudo do-release-upgrade Checking for a new ubuntu release No new release found This is running from behind a proxy, but I've set it up such that the regular upgrades and apt-get etc doesn't complain. (export http_proxy=http://myuser:mypass@myserver:8080/) Could you think of anything else which might be stopping me from upgrading?

    Read the article

  • Remap key combinations in Windows

    - by nickf
    This question is similar to this one, but the accepted solution doesn't work in my case. I work on two different laptops. On one, the Home and End keys are only available by pressing Fn+Left and Fn+Right. This can make it rather annoying when switching between the two since I always go to press Fn-Right and not get what I want. The tool suggested in the other question is Sharpkeys, however it doesn't recognise Fn+Right as a different key from Right, and I suspect that registry twiddling isn't going to help me here. (?) Is there any way to remap this combination? (I'm on Windows Vista if that helps)

    Read the article

  • Photoshop: Trim a photo so it contains no transparent pixels?

    - by nickf
    In Photoshop, I've put together some panorama photos using the Photomerge tool and the resulting image contains a lot of transparent pixels. Also, because it's put together of multiple photos the alignment can be off. What I'd like to do is cut the image down to the largest box which contains no transparent pixels at all. It's similar to the Trim tool, but this would remove a number of non-transparent pixels. Is there anything like this? Basically something which would automatically crop the above image to the selection box there: a rectangle with no transparent pixels.

    Read the article

  • Highlight a word with jQuery

    - by nickf
    I basically need to highlight a particular word in a block of text. For example, pretend I wanted to highlight the word "dolor" in this text: <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </p> <p> Quisque bibendum sem ut lacus. Integer dolor ullamcorper libero. Aliquam rhoncus eros at augue. Suspendisse vitae mauris. </p> How do I convert the above to something like this: <p> Lorem ipsum <span class="myClass">dolor</span> sit amet, consectetuer adipiscing elit. </p> <p> Quisque bibendum sem ut lacus. Integer <span class="myClass">dolor</span> ullamcorper libero. Aliquam rhoncus eros at augue. Suspendisse vitae mauris. </p> Is this possible with jQuery? Edit: As Sebastian pointed out, this is quite possible without jQuery - but I was hoping there might be a special method of jQuery which would let you do selectors on the text itself. I'm already using jQuery heavily on this site, so keeping everything wrapped up in jQuery would make things perhaps a bit more tidy.

    Read the article

  • PHP intersection between array and object

    - by nickf
    I have an object, let's say it's like this: class Foo { var $b, $a, $r; function __construct($B, $A, $R) { $this->b = $B; $this->a = $A; $this->r = $R; } } $f = new Foo(1, 2, 3); I want to get an arbitrary slice of this object's properties as an array. $desiredProperties = array('b', 'r'); $output = magicHere($foo, $desiredProperties); print_r($output); // array( // "b" => 1, // "r" => 3 // )

    Read the article

  • Algorithm to determine thread "hotness"

    - by nickf
    I'm trying to come up with a way to determine how "hot" certain threads are in a forum. What criteria would you use and why? How would these come together to give a hotness score? The criteria I'm thinking of include: how many replies how long since the last reply average time between replies The problems this algorithm must solve: A thread which has 500 replies is clearly hot, unless the last reply was over a year ago. A thread with 500 replies that was replied to a second ago is clearly hot, unless it's taken 4 years to reach 500 replies. A thread with 15 replies in the last 4 minutes is really hot! Any ideas, thoughts or complete solutions out there?

    Read the article

  • User agent string of Opera Mini on iPhone

    - by nickf
    So hell froze over and Apple accepted Opera Mini into the app store. Does anyone know what the user agent string will be? The documentation says that Opera's template is like this: Opera/9.80 (J2ME/MIDP; Opera Mini/$CLIENT_VERSION/$SERVER_VERSION; U; $LANGUAGE) Presto/$PRESTO_VERSION

    Read the article

  • Algorithm to generate a crossword

    - by nickf
    Given a list of words, how would you go about arranging them into a crossword grid? It wouldn't have to be like a "proper" crossword puzzle which is symmetrical or anything like that: basically just output a starting position and direction for each word.

    Read the article

  • Debugging mod_rewrite

    - by nickf
    I'm playing around with Apache's mod_rewrite module, and want to know if there is a decent way to output some debugging information? For example, the documentation lists a number of variables available: %{HTTP_USER_AGENT}, %{HTTP_REFERER}, %{HTTP_COOKIE} ... etc Is there a way I could output these just to see what I'm working with? I set up the RewriteLog (Level 2) and have been looking at that, but it'd be nice to be able to see the value of the variables.

    Read the article

  • Problem with IE using 960.gs

    - by nickf
    I'm using the 960.gs CSS framework on a site and have hit problems almost instantly with IE (7, though I assume 6 is no better). <html> <head> <link rel="stylesheet" href="design/reset.css" /> <link rel="stylesheet" href="design/960.css" /> <link rel="stylesheet" href="design/text.css" /> </head> <body> <div class="container_12">abc</div> </body> </html> Given this HTML above (the CSS is just the files bundled with 960), Firefox and Chrome centre the grid, whereas IE pushes it to the left. I've used 960 before without any issues, so I think I must just be doing something really stupid. Can anyone help?

    Read the article

  • Does a transaction stop all race condition problems in MySQL?

    - by nickf
    Consider this situation: Begin transaction Insert 20 records into a table with an auto_increment key Get the first insert id (let's say it's 153) Update all records in that table where id >= 153 Commit Is step 4 safe? That is, if another request comes in almost precisely at the same time, and inserts another 20 records after step 2 above, but before step 4, will there be a race condition?

    Read the article

  • What do you call functions which get and set?

    - by nickf
    The jQuery framework has a lot of functions which will either retrieve or mutate values depending on the parameters passed: $(this).html(); // get the html $(this).html('blah'); // set the html Is there a standard name for functions which behave like this?

    Read the article

  • How to document an accessor/mutator method in phpDoc/javaDoc?

    - by nickf
    Given a function which behaves as either a mutator or accessor depending on the arguments passed to it, like this: // in PHP, you can pass any number of arguments to a function... function cache($cacheName) { $arguments = func_get_args(); if (count($arguments) >= 2) { // two arguments passed. MUTATOR. $value = $arguments[1]; // use the second as the value $this->cache[$cacheName] = $value; // *change* the stored value } else { // 1 argument passed, ACCESSOR return $this->cache[$cacheName]; // *get* the stored value } } cache('foo', 'bar'); // nothing returned cache('foo') // 'bar' returned How do you document this in PHPDoc or a similar automated documentation creator? I had originally just written it like this: /** * Blah blah blah, you can use this as both a mutator and an accessor: * As an accessor: * @param $cacheName name of the variable to GET * @return string the value... * * As a mutator: * @param $cacheName name of the variable to SET * @param $value the value to set * @return void */ However, when this is run through phpDoc, it complains because there are 2 return tags, and the first @param $cacheName description is overwritten by the second. Is there a way around this?

    Read the article

  • Problem with Ruby script output being stored into a file

    - by nickf
    I have a Ruby script that outputs a heap of text. As an example: puts "line 1" puts "line 2" puts "line 3" # etc... (obviously, this isn't how my script works..) There's not a lot of data - perhaps about 8kb of character data in total. When I run the script on the command line, it works as expected: $ ./my-script.rb line 1 line 2 line 3 But, when I push it into a file, the output is truncated at exactly 4096 bytes: $ ./my-script.rb > output.txt What would cause it to stop at 4kb?

    Read the article

  • Does MySQL short-circuit the ORDER BY clause?

    - by nickf
    Given this SQL: SELECT * FROM mytable ORDER BY mycolumn, RAND() Assuming that mycolumn happens to only contain unique values (and hence, contains enough information to perform the ORDER BY), does MySQL short-circuit the operation and skip evaluating the rest?

    Read the article

  • How to (kindly) ask your users to upgrade from IE6?

    - by nickf
    It's no secret at all that IE6 has been a major roadblock to the advancement of the web over the last few years. I couldn't count the number of hours I've spent bashing my head against a wall trying to fix or debug IE6 issues. The way I see it, there are two types of IE6 user. a) the poor corporate schmoe whose IT department doesn't want to upgrade in case something breaks, and b) the mums and dads of the world who think the internet is the blue E on their desktop (and I don't mean that in a nasty way). There's probably a couple of people who know about all the other browsers, but still choose to run IE6. They get what they deserve, IMO. Anyway, getting to the point, I'd say that 90% of my IE6-using visitors are in the the mums and dads category - they're not stupid, they just don't know WHY they should upgrade to IE7 or Firefox or whatever. How do I educate these people without pissing them off? Is there a nice and friendly website I can direct these people to, which explains the reasons for upgrading in plain language? Any mention of "security" or "web standards" I think would just come across as scary. I've just seen http://www.whatbrowser.org which seems to fit the bill nicely. It explains in very basic terms: what a web browser is why you'd want to upgrade it how old your current browser is (subtle hint to those with a 9 year old browser) ..aaaand it's in 22 languages. It's from Google but displays no bias (it links to Firefox, Chrome, Opera, Safari, Internet Explorer displayed in a random order).

    Read the article

  • Posting null values via AJAX

    - by nickf
    Using the jQuery $.post function, if you send a null value, it arrives at the server side as "null". Example: Javascript: $.post('test.php', { foo : null }); PHP: var_dump($_POST['foo']); // string(4) "null" I understand why this is so, but was wondering the best way to work around the limitation? Should you: Loop through all the variables in JS before you send them and replace with an empty string? Interpret "null" as null on the server side? Don't send the variable at all? Something else?

    Read the article

1 2  | Next Page >