Posts

python - MySQL Query to fuzzy(?) search a software database -

i have software names database need search ,now trying find query select right software name . software name field varchar example software list in db: adobe flash professional mozilla firefox browser 20.0 adobe photoshop lightroom netbeans ide winrar 5.10 beta 2 query firefox be: firefox or mozilla firefox query lightroom be: lightroom or adobe lightroom or photoshop lightroom query winrar be: winrar or winrar archiver i have tried work soundex or levenshtein distance , not return desired result . you looking fulltext searching: https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html note need create fulltext index on searched column, , may want consider adding relevant keywords (so abovementioned "archiver" matches on something)

c++ - c++11 equivalent of c# Interlocked.Increment -

i'm rewriting c# code c++: public class lightorder { private static int internalidcounter; public int internalid { get; private set; } // control myself call method once each order public void assigninternalid(int ordersexecutorid) { // if internalid assigned, i.e. != 0, can print error or internalid = interlocked.increment(ref internalidcounter); // more } // more } this works fine - each order has sequential id if assigninternalid called different threads parallel. what closest c++ equavalent code? should declare internalid std::atomic<int> , use ++ ? or should declare internalid int , use std::atomic_fetch_add ? should declare internalid std::atomic<int> , use ++ ? yes. or should declare internalid int , use std::atomic_fetch_add ? no. functions atomic_fetch_add work on atomic types (specialisations of atomic , or types atomic_int ), you'd still need atomic type. ...

c# - How to show a picture box inside a panel on hover programmatically? -

i have following problem, because quite new don't know if asking right questions...hope can put me in right direction, in advance. i have panel. inside there textbox(same size panel(140*40) , picturebox(smaller , in right top corner, 15*15).at moment able when mousehover panel(and textbox) show picturebox image deleting in it. if pass mouse on picturebox himself dissapears, , want happens when mouseleave textbox or panel. a college told me must use parent property, have no idea how can that. i don't know if explanation good, leave code here, can point me solution. textbox tbrole , panel pnrole , picturebox pbdeletex : tbrole.mousemove += (senderl, el) => { if (mousehover) { pbdeletex.visible = true; mousehover = true; } else { pbdeletex.visible = true; mousehover = false; } tbrole.backcolor = col...

c - How does preprocessor make that expansion (define macro found in included header file ) -

i have header file contain constant f_cpu , use macro guard header.h #ifndef f_cpu #define f_cpu 1000000ul #endif and source.c file #define f_cpu 16000000ul #include "header.h" how first macro(in c file ) expand value not included yet? use -e option of preprocessor follow happens. define f_cpu macro in first line of source.c , after when header file included, macro definition in header not takes place because of #ifndef guard. note there no macro expansion in code. expansion takes place when use macro.

mysql - Calculating average from 2 database table colums -

i trying calculate average based on values 2 table columns in mysql . lets have table structure: id | user_id | first_score | last_score 1 | 1 | 10 | 60 2 | 1 | 70 | 10 3 | 1 | 100 | null what trying achieve here, calculating avg of highest value (i.e. 60, 70, 100). seeing in different colums, not sure how go it.. you solve greatest function. unfortunately results in null when 1 or both values null. so: select avg( greatest( coalesce(first_score,last_score) , coalesce(last_score,first_score) ) ) mytable;

grep command to match only request url of access log -

i need find accessed urls having keywords config,tmp,backup or dump. grep '/config/\|/tmp/\|/backup/\|/dump/' access.log when grep access log getting unwanted logs below 106.221.160.250 - - [11/apr/2014:12:07:13 -0400] "get url.com/perfect http/1.1" 200 43 "file:///something/tmp/579928.html" "htc_smart_f3188 mozilla/5.0 (like gecko) obigo/q7" 0 20675 it's unwanted get url.com/perfect http/1.1" 200 43 "file:///something/tmp/579928.html doesn't contain desired keyword. how should change grep command? try this: grep 'tmp\|config\|backup\|dump' accessl.log

linux - "cannot write to log file pg_upgrade_internal.log" when upgrading from Postgresql 9.1 to 9.3 -

i keep on getting above error whenever run following command via postgres user. /usr/lib/postgresql/9.3/bin/pg_upgrade \ -b /usr/lib/postgresql/9.1/bin/ \ -b /usr/lib/postgresql/9.3/bin/ \ -d /var/lib/postgresql/9.1/main \ -d /var/lib/postgresql/9.3/main cannot write log file pg_upgrade_internal.log failure, exiting i'm using ubuntu 13.10. both postgresql 9.1 , 9.3 running properly. make sure run command directory writable postgres user, /tmp or /var/lib/postgresql : $ cd /tmp $ usr/lib/postgresql/9.3/bin/pg_upgrade ...