Posts

Showing posts from May, 2012

Device information on com port c# -

i had such problem: in 3 com ports have devices work in software. not installed drivers. problem is: how can find out of ports connected of device? in advance you may not able identify devices in com ports. there no industry standard nor requirement device names. protocols such scsi, atapi , usb have commands can use identify device. standard rs232, there no such requirement. what kind of devices have identify? plotters, thumbdrives, tape drives, etc?

javascript - getComputedStyle() and properties that can have a url associated with them -

i'm trying make snippet of javascript can list of images (or other resources) used in web page because referenced in css. typically background images, because somewhere in css there this: .something { background: transparent url(images/somethingbg.png) no-repeat top left; } it seems can of these array (with full path) following snippet: var outputarray = []; var string = ""; var elems = document.getelementsbytagname('*'); (var = 0; i<elems.length; i++) { var elem = elems[i]; var style = window.getcomputedstyle(elem, null); var value = style.getpropertyvalue("background-image"); if (value && value != "" && value != "none") outputarray.push(value); } however, want work on file out there (running bookmarklet), , know url() can apply things aren't background images, instance "list-style-image". there more? there list of these somewhere? afaik here's pretty exhaustive

MySQL Make a combination of columns unique -

i have table stores comments users make images on site. table structured 4 columns, row_id, primary key, image_id, user_id , comment. want ensure user can leave 1 comment per image. create unique index on 2 columns? create unique index imgusr on comments (image_id, user_id); the idea following query work: insert comments set image_id = '1', user_id = '2', comment = 'nice' on duplicate key update comment = 'nice'; the gotchya (gotme?) table innodb because expected large. approach work, despite presence of primary key? yes work perfectly. in topic, why did have row_id ? can put primary key (image_id, user_id) , works too.

Scala method to combine each element of an iterable with each element of another? -

if have this: val = array("a ","b ","c ") val b = array("x","y") i know if such method exists let me traverse first collection, , each of it's elements, walk entire second collection. example, if take array a , have a,x , a,y , b,x , b,y , c,x , c,y . know of zip i've seen works on collections of same sizes, , associates elements same positions. i'm not sure of "method", can expressed nested/compound for : val = array("a ","b ","c ") val b = array("x","y") (a_ <- a; b_ <- b) yield (a_, b_) res0: array[(java.lang.string, java.lang.string)] = array((a ,x), (a ,y), (b ,x), (b ,y), (c ,x), (c ,y)) happy coding.

c# - Programatically check which versions of .NET Compact Framework are installed -

i have windows mobile application built .net cf 1.0. written in c#. how can program check versions of .net compact framework installed on device running on? it depends on mean "installed". if installed via cab file (the common), there entries in registry under hkey_local_machine\software\microsoft\.netcompactframework programmatically check.

linux kernel - Can someone help me replace "lock_kernel" on a block device driver? -

thank looking @ post. trying patch network block device driver. if need see sources @ http : / / code.ximeta.com. i noticed lock_kernel() seems deprecated of linux 2.6.37. read "the new way of ioctl()" , found device drivers should perform specific lock before operating. so advice replacing if possible. i have found 2 sections in current code think related, in block folder section. source block->io.c ->ctrldev.c i put snippets each consideration. io.c contains 1 call lock_kernel: ndas_sal_api xbool sal_file_get_size(sal_file file, xuint64* size) { definitions , declarations etc.. lock_kernel(); #ifdef have_unlocked_ioctl if (filp->f_op->unlocked_ioctl) { small statements error = filp->f_op->unlocked_ioctl(filp, blkgetsize64, (unsigned long)size); actions if error or not etc. } #endif unlock_kernel(); return ret; } and ctrldev.c contains main io function: #include <

screensaver - How to make unlock screen app for Android -

i trying develop unlock screen app android. have downloaded unlock screen app , tested. found 1 app. fingerprint screensaver . want. mean wish replace pattern unlock screen app. wandering how replace android pattern unlock screen app. i have googled lot, not find how it. wrote hack. android not support, wish know how that. if knows it, please give me clue. in advance lot. thanks. you can create custom unlock screen adding following intent filter androidmanifest.xml file activity: <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home" /> <category android:name="android.intent.category.default" /> </intent-filter> this hack because dialog box pop asking user 1 wants use (yours or default). worse, if user accidentally selects lock screen default home screen in chooser, mess device. might end having factory reset. the safe way cre

javascript - getting requestheaders from XHR -

i need access requestheaders in onload function. how can ? thanks if want access cookies within javascript can read them using document.cookie : allcookies = document.cookie; allcookies string containing semicolon-separated list of cookies (i.e. key=value pairs)

shopping cart - How to store information in a field in Database? -

ok building simple shopping cart website , have researched question, have been unsuccessful @ finding answer. i have these tables far: item ------ id categoryid brandid name price categories ----------- id name brands ------- id name shopping carts -------------- id userid itemids itemprices itemquantities based on other answers have found seems correct way, except not sure shopping carts table. considering storing information in table so: id: 1 userid: 1 itemids: 1;2;3;5 itemprices: 40;50;60;70 itemquantities: 1;2;3;4 is correct way of tackling or there better way? (i thinking of using explode() function in php separating data when retrieving it.) ideally, want store shopping cart info either in cookies or in sessions. if want store each shopping cart in db, use following implementation. essentially, 1 shopping cart can have multiple items, each item having price , quantity associated it. for storing carts per user, use schema: shopping carts

ios4 - Objective C variable accessible by multiple methods -

this second day programming in objectivec apologize noob question. i have viewcontroller api call using async , asihttprequest: @synthesize loadingstatus; - (void)loadstatsdata { [indicator sethidden:no]; loadingstatus = [nsdictionary dictionarywithobjects:[nsarray arraywithobjects:@"bad", nil] forkeys:[nsarray arraywithobjects:@"amount", nil ] ]; [restapicontroller request:@"/method.json" method:@"get" options:[nsdictionary dictionarywithobjects:[nsarray arraywithobject:@"amount"] forkeys:[nsarray arraywithobject:@"receiving"] ] parent:self]; } and receiving this: - (void)requestfinished:(asihttprequest *)request { if (receiving == @"amount") { // stuff [loadingstatus setvalue:@"good" forkey:@"amount"]; } if ([loadingstatus valueforkey:@"amount"] == @"good"]) [indicator sethidden:yes]; } the app crashes when tries

sql - An Access problem: Not getting required output while building a report -

i have created report in access , have written query fetching records multiple tables follows: select buildingdetails.*, contractors.item, actiondetails.actiontype contractors inner join (buildingdetails inner join (actiondetails inner join dormdata on actiondetails.actionid = dormdata.actionid) on buildingdetails.buildingid = dormdata.buildingid) on contractors.id = dormdata.itemid; now want actiontype=repair or actionid=1 retrieved query. have 2 actontype "repair" , "replace". i suspect need filter using actiontype = 'repair' (i further guess actionid autonumber , have row {actionid = 1, actiontype = 'repair'} chance... maybe extrapolating far :) i'm surprised @david steele's answer works in access (ace, jet, whatever) because he's removed parentheses join clauses (however if -- suggesting linked table -- should "accept" answer). resist 'neatening them up' on clauses clo

is there any simple way to format the date in php? -

is there function format kind of '5/1/2011' date '2011,1,5' in php you can via regular expression : $new_str = preg_replace('#(\d+)/(\d+)/(\d+)#', '$3,$2,$1', $str);

xml - Triple Slash Comments in C? -

this quick, no-brainer question, haven't been able find answer on google. of coding in c# , typing bit of c, , wondering if c supports triple-slash comments or if spoiled being able use them. thanks! c not have equivalent of xml documentation comments or javadoc. try doxygen .

perl - Dumping hash of arrays to file -

how can dump hash of arrays file? each hash keys name of folder , array of files listed in folder. here working on, open outfile, "> output.txt" or die $!; foreach $key (keys %folder_structure) { print outfile "$key\n"; foreach $line (@{$folder_structure{$key}}) { print outfile "$line\n"; } } close outfile; if not have specific requirement output format, simplest way use data::dumper: use strict; use data::dumper; open outfile, "> output.txt" or die $1; print outfile dumper \%folder_structure; close outfile; edit: per comments, dumper being passed reference hash, not hash itself. the data::dumper module has settings control output, can read on cpan page .

jquery - display alt image in IE, because it doesnt display sparkline -

we use peity display sparkline graphs. the code have js is: ( hope correct , works fien in chrome , ff ) $(function(){ $(".line").peity("line",{ colour: "#c6d9fd", strokecolour:"#4d89f9", strokewidth:1, width:200, height:44 } ); }); the code display sparkline is: <span class="line">1,23,4,7,5,9,10</span> within ie, not display sparkline, , rather have show: 1,23,4,7,5,9,10 i display else, perhaps small png image etc. dooable. like: if ie display blah blah blah you can write if ($.browser.msie && $.browser.version < 9)

javascript resize iframe height dynamically issue -

i'm having issue resizing iframe fit content located within frame'd page. used suggestion found here resize frame dynamically. in frame'd pages have <body onload='parent.resizeiframe(getdocheight())'> function getdocheight() { var d = document; alert(d.url); return math.max( math.max(d.body.scrollheight, d.documentelement.scrollheight), math.max(d.body.offsetheight, d.documentelement.offsetheight), math.max(d.body.clientheight, d.documentelement.clientheight) ); } and in page containing iframe have this function resizeiframe(newheight) { var showsframe = document.getelementbyid('frm'); showsframe.style.height = parseint(newheight) +'px'; } the function getting called correctly each frame'd page, reason 'newheight' parameter being passed keeping largest height value. example if have 2 frame'd pages 1 scroll height of 300px , other 500px. when first click link load 300px page works fine, if click

Mysql - ORDER BY - Can to use condition? -

i sort list date_modified desc this problem when new record input, date_modified null date 0000-00-00 00:00:00 so record in bottom, not top of list. how sort ? :( note: don't insert date_modified date , because have field date_create order coalesce(date_modified, date_created) desc; but, performance better if set date_modified current_timestamp when doing insert, suggested.

html - Adding Some "Spacers" to a Table -

Image
here's fiddle: http://jsfiddle.net/6yu6n/ here's mockup of want accomplish: as can see, want add tiny space between header , first "pick container." , add space between each pick container. what's best this? you can use need space: .... <tr class="big_gap"> <td colspan="4"></td> </tr> ... <tr class="small_gap"> <td colspan="4"></td> </tr> .... <style> .big_gap td { height: 19px; } .small_gap td { height: 10px; } </style> this way can give specific appearance gap in between. , if doesnt behave can add   in <td colpan="4">&nbsp;</td>

iphone - How can you launch a URL from the iOS Settings Bundle? -

i launch url ios settings bundle @ least launch safari when touched setting. not sure if possible couldn't find examples of in settings area apple or 3rd party apps. if not appreciate confirmation this. you can't. current settings.bundle able only display or change values . better check apple docs settings application schema reference , few available element types. sorry.

Rails 3 Routes issue on form Edit -

basically whats happening can create new item gets saved table in db. when go edit item, form opens up, make change , when go submit, takes me same url edit page , gives me routing error no route matches "/support/14/edit" although if enter in address bar opens edit form fine, doesn't have of changes saved. here code. routes.rb resources :support support_controller.rb def new @support_item = support.new respond_to |format| format.html # new.html.erb format.xml { render :xml => @support_item } end end # /support/1/edit def edit @support_item = support.find(params[:id]) end # post /support # post /support.xml def create @support_item = support.new(params[:support_item]) respond_to |format| if @support_item.save format.html { redirect_to("/support", :notice => 'question created.') } else format.html { render :action => "new" } end end end # put /support/1 # put /support/1.xml

delphi - Running an ActiveX DLL in firefox -

hello guys: have written activex dll in delphi , want run in in firefox. how can that? is there anyway can make .xpt directly form dll or not? i'm afraid there no way make .xpi directly dll. activex control needs activex host firefox not, default. seems can be, however, installed plugin. quick google search "firefox activex" reveals: ff-activex-host neptune mozilla activex project (seems abandoned there's reference , source code firefox 1.x)

oop - Symbol Table scope in compilers for object oriented languages -

i'm building symbol table compiler of subset of c++. my question here how deal scope in objects. mean, in normal language such pascal should create symbol table every scope. c++ should consider approche case of methods , attrubtes of object? regards. i'd object has symbol table every scope methods , attributes, plus table friend class , methods. it's idea.

Excel VBA - Copy entire columns from closed Workbook -

i've got excel workbook lot of information want pull out , insert new workbook macro contained. what i'm after general function takes couple of arguments sourcefile , column. need columns, entire column source file. this how i'm picturing function (pseudo code) public function getcolumnfromworkbook(byval strsourcefile, byval sourceworksheet) application.screenupdating = false set wb = workbooks.open(strsourcefile, true, true) thisworkbook.worksheets(destsheet) .column(1) = wb.worksheets(sourceworksheet).columns(sourcecolumn) end end function the function above don't work. might show i'm after :) this seems work me - note have extended parameter list. no error checking. public function getcolumnfromworkbook(byval strsourcefile string, byval sourceworksheetname string, byval sourcecolumn long, byval destsheet worksheet) application.screenupdating = false dim wb workbook set wb = workbooks.open(strso

java - JFrame to Window class -

i want know line code true or there better way? can 1 me? jframe jframe=new jframe() window window; jframe.setundecorated(true); window=(window)jframe; //is line true? thank you. yes it's true don't need cast. java.swing.jframe child class of java.awt.window it's ok. , can't find reason why method applied window variable wouldn't apply jframe variable. it's not supposed happen java uses late binding method calls. try review code, check if import right classes, because think you're misunderstanding something.

How to process/eval $ajax response as html/javascript when loading into a jquery dialog in MVC 3? -

i have index page list of users , edit link. when click link wold open jquery dialog edit , save. i doing ajax on view , loading return data div. return data html , javascript both. return text essentially. need javascript in return executed, sort of running eval. possible or there better way it? guess open in window.open or iframe. wondering if jquery dialog or other model dialog solution possible? there recommended way? $.ajax({ type: "get", url: "/user/edit/" + user.id, cache: false, datatype: 'html', error: function (xmlhttprequest) { $("#edit-dialog").html(xmlhttprequest.responsetext); }, success: function (data) { $("#edit-dialog").html(data); $("#edit-dialog").dialog("open"); } }); the page edit

PowerShell foreach file in folder using a lot of memory -

i'm new powershell , programming, i'm sure code can optimized more. however, biggest problem code puts it's data foreach loop in memory. best way prevent this? i started rewriting script script found here: powershell: delete files older x days edit: oh, there 60 000~ files in each targetfolder way. ## set window title $title = $host.ui.rawui.windowtitle $titdef = $title $host.ui.rawui.windowtitle = "checking files. not close " + "($title)" ## debug (0=nothing, 1=extended log, 2=extended log+screen) $debug = "2" ## log file $log = "c:\status\status.txt" add-content $log "nul" ## clear log before adding new data remove-item $log ## folders check $targetfolder1 = “\\server\c$\biztalkprojects\udc\output\ume” $targetfolder2 = “\\server\c$\biztalkprojects\udc\output\upp” ## required stuff $now = get-date $days = “2” $twodays = $now.adddays(-$days) $folder1 = get-childitem $targetfolder1 -include * $folder2 = get-

java - Implementing a Gallery with pinch zoom -

i have gallery of images , i'm trying enable pinch zoom on it. separately, work fine. problem is, can't life of me bind 2 of them together! tried bind imagezoomview in imageadapter, no avail. should try doing when user clicks image? have other ideas? code in imageadapter.class returns gallery elements: public view getview(int position, view convertview, viewgroup parent) { imageview = new imageview(mcontext); bitmap bitmap = bitmapfactory.decoderesource(mcontext.getresources(),mimageids[position]); i.setlayoutparams(new gallery.layoutparams(300, 450)); i.setscaletype(imageview.scaletype.fit_xy); i.setbackgroundresource(mgalleryitembackground); i.setimagebitmap(bitmap); return i; } and how handle in mainactivity.class: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.gallery); gallery g = (gallery) findviewbyid(r.id.gallery); g.setadapter(n

http - question about size (bytes) of webpage retrieved using erlang -

i have got question http:request(...) in erlang. when retrieve page using above command (for example main page of apache webserver), have in headers list value {"content-length","177"} , seems right, because using byte_size(...) on body of page same result..this suggests me size of page 177 bytes. i checked result using tools -> page info option in firefox, says size 146 bytes...can tell me why there difference? in http specification (rfc 2616) section 14. definition of content-lenght header: 14.13 content-length the content-length entity-header field indicates size of entity-body, in decimal number of octets, sent recipient or, in case of head method, size of entity-body have been sent had request been get. so either firefox wrong, got different content or shows size different definition of "size".

java - Problem with Date format using an attribute Calendar with JPA -

i've problem using attribute calendar jpa: @column(name = "date") @temporal(temporaltype.date) private calendar date; by default setted mm/dd/yyyy , need in dd/mm/yyyy, can me? i've seen quiete easy date instead of calendar can't use it... thx daniele i think, format doesn't matter. neither calendar nor date have format them. tostring() method formats in default format. would care elaborate, what expected behaviour? what getting? [edited based on comment below] whatever, comes browser comes string . so, having issue while converting string date or calendar . fix , after that. happy coding. cheers.

user interface - Android: How can I access the default text color? (No theme, just the standard one) -

very short question: if want set text (in textview) default text color, how can this? i'm not using themes. i used following way: @ initialization backuped default color , when had reset used stores value.

c - How can I compile code that uses getsubopt()? -

i want parse list of options of form key1=val1, key2=val2, etc (like options mount -o ). getsubopt() function seems perfect task ( http://www.gnu.org/s/hello/manual/libc/suboptions.html ). however, when try compile code using gcc, get: warning: implicit declaration of function ‘getsubopt’ and program segfaults when run it. do have: #define _xopen_source 500 #include <stdlib.h> at top of file contains call subopt ? error getting expect if call function has not been declared.

php - sfErrorNotifierPlugin on symfony task -

my application runs huge batch processing inside symfony task, , want notified php errors , uncaught exceptions. so tried sferrornotifierplugin, , works great in web context (accessing application browser); problem can't make work on symfony tasks. is there way make work in tasks? sftask has no exception handling web interface does, can work around it: exceptions thrown passed sferrornotifier::notifyexception . wrap task's execute method in big try-catch block: public function execute($arguments = array(), $options = array()) { try { //your code here } catch(exception $e) { sferrornotifier::notifyexception($e); //call notifier throw $e; //rethrow stop execution , avoid problems in special cases } } keep in mind needs application parameter run correctly (uses settings app.yml).

cocoa - webview + html5 video is not working -

i'm developing application has display html content contains html5 video (no flash/silverlight plugins). html , video playing fine in safari, when displayed inside webview in application black box video should be. video seems playing, because if click fullscreen, video goes fullscreen , correclty displayed, , audio present, in fullscreen , non fullscreen mode. seems video played behind page. maybe i'm missing newbe? does has html5 video correctly displayed inside webview on mac os x 10.6? thanks lot!

Spring AOP: Disadvantages when using it - Spring Features which use Spring AOP do not have this disadvantages? -

im working spring framework 3.0.5 , spring security 3.0.5 , ive got questions aspect orientated programming. @ moment im trying figure out disadvantages , advantages of aspect orientated programming. of course, know them in theory: can avoid redundant code, have make changes in aspect, not everywhere in code , on. still got questions: the disadvantage found out: i wrote sample application using aspects spring aop. configured aspect annotations (@pointcut, @before, @aspect , one). methods triggered aspect (which part of pointcut of course) of course part of different class , not annotated anything. => think 1 big disadvantage when watching methods of other class not clear trigger aspect. needed no annotations or else, mentioned in pointcut of aspect. (i hope understand mean). thats why think aop makes code less understandable! a) there solution problem? (can maybe solved when put whole configuration in xml file? dont think so.) b) problem still exist when use aspe

xslt - Using XSL/XPath to match nodes with any name having a given attribute and child-node -

i'm trying use xpath/xslt add node existing node fulfills requirements: the node has attribute "id" the node has child named "type", containing given text, e.g. "identifier" in xml match: <somerandomnode> <type>somerandomtype</type> <child> <count type="int32">2</count> <!-- node should matched --> <key id="5"> <type>identifier</type> <somevalue type="string">hello</somevalue> <someothervalue type="string">world</someothervalue> </key> </child> </somerandomnode> </project> i'm having hard time writing match expression this, "best" attempt being: <xsl:template match="*[@id][.//typename='identifier']"> <xsl:copy> <xsl:attribute name="id"> <xsl:valu

javascript - Getting the Nth user who like a page I am the admin of on Facebook -

what find out userid of nth user page. so far thinking not going possible. have found following http://www.facebook.com/browse/?type=page_fans&page_id=[page_id] seems show of users first 400/500 i thought may have been possible using fql thinking not going since page_id not indexable column. http://developers.facebook.com/docs/reference/fql/page_fan/ saying found following stackoverflow question suggests possible not provide code facebook api: fans of / people page , following post got me hopeful can list of people have facebook-liked page? checking http://developers.facebook.com/docs/reference/fql/like/ looks wont work it points page seems point fact not possible, retrieve facebook fan names (this answer seems voted retrieve facebook fan names ). following post seems yes , no @ same time querying users 'like' facebook page . right in assuming not possible? appears bug. see https://developers.facebook.com/bugs/231272073596022 wonder if give

JNI - sending class instances to C++ -

i want send struct-like object java c++. since there no structs in java guess have write class , send instance of class. public class soundsource { int posx; int posy; ..... } but... jobject jni method in c++ - how extract individual fields? thanks dennis's answer correct, however, there's way can this, might give better performance, , via direct byte-buffers. here docs need read: jni nio support , bytebuffer you allocate direct byte-buffer either on java side or c side. populate buffer, on java side, using bytebuffer's methods, according c-struct's layout. remember these buffers must deallocated when you're done using them, can reuse same buffer pass data back-and-forth.

jsf - Is there any FacesConfirm class like FacesMessage -

is there facesconfirm facesmessage ? need pass confirmation dialog instead of message. facesmessage msg = new facesmessage("the version " + version + " exists.", " import data replace existing data."); facescontext.getcurrentinstance().addmessage(null, msg); no. render <script> conditionally. <h:panelgroup rendered="#{not empty bean.confirmmessage}"> <script>confirm('#{bean.confirmmessage}');</script> </h:panelgroup> or use 3rd party jsf component library uses similar mechanism, such primefaces' <p:confirmdialog> .

c# - Sending an email with a link that will post the user to a particular page that i have got! -

basically, can send user emails. tried send him this: mailmessage message = new mailmessage() { subject = "yourguru account", body = "thanks joining our site. click th link below validate account"+ "<br/>"+ httpcontext.current.request.url.host }; message.to.add(new mailaddress("makovetskiyd@yahoo.co.uk", "some name")); message.isbodyhtml = true; smtpclient client = new smtpclient(); client.enablessl = true; client.send(message); response.redirect("checkyouremail.aspx"); the httpcontext.current.request.url.host function appears in email "localhost"..but need appear real link..that press , redirects me. use visual studio 2010 it seems using httpcontext.current.request.url.host instead of httpcontext.current.request.url for local dev environment getting localhost , when deploy web server, correctly update hosted web server url. ideally, have path contain q

c# - How can I make word visible when opening a document through interop? -

i want open word document through interop , word must visible in process.it looks straight forward because there parameter called "visible in open function on word document. word in background. missing? static void main(string[] args) { microsoft.office.interop.word.application word = null; word = new microsoft.office.interop.word.application(); object inputfile = "c:\\test.docx"; object confirmconversions = false; object readonly = true; object visible = true; object missing = type.missing; // open document... microsoft.office.interop.word.document doc = null; doc = word.documents.open( ref inputfile, ref confirmconversions, ref readonly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref visible, ref missing, ref missing, ref missing, ref missing); doc.activate(); console.readkey(); } hmm. apparantly both application

ssrs 2008 - Nested tables in SQL Server Reporting Services without using Subreports -

i'd achieve somthing similar nested products , orders tables shown in xtrareports example using sql server reporting services. also i'd prefer without using subreports.

full text search - SqlServer 2008 - deleting rows containing terms found in a black list table -

i have 2 tables, 1 list of strings , other contains list of black listed words. wish find rows in first table string contains word second. using statement created following script , worked: select a.string a left join blacklist b on a.string '%' + b.term + '%' b.term null i wanted use full text search better performance. looking way this: select a.string a left join blacklist b on contains(a.string, b.term) b.term null my research on web discovered not possible, way of doing this? you need run row row try cross apply. no match = no row cross apply query same left join..is null select a.string a cross apply (select b.term blacklist b contains(a.string, b.term)) foo

performance - What's the speed of texture upload? -

i upload 2 images gpu memory, , i'm interested how fast can this? in fact - faster compare 2 bitmaps in ram cpu, or upload them gpu , use gpu parallelism it? if run cuda device bandwidth sample, you'll benchmark upload speed. assuming ddr3 tri-channel 1600mhz ram, you'll 38 gb/s memory bandwidth. take typical midrange card gtx460 , you'll 84 gb/s memory bandwidth. note you'll have make hop across bus 8gb/s theoretical, ~5.5 in practice pci-e2.0 x16 link. note kotlinski's answer isn't quite correct. you'll can compared in parallel , parallel reduction in case, bigger gpu device bandwidth can work win out eventually. i think answer be: loss upload gpu , comparison once. possible gain if comparison made multiple times (kept , modified on gpu, example). edit: the multiple times comparison refers if modified images on gpu memory in situ. thus, merit comparison (caching doesn't cut it), while not incurring penalty of copy across

c++ - error LNK2001: unresolved external symbol _IID_IDirectDraw2 -

i work piece of legacy code uses direct draw , i'm in rather embarrassing situation. not long ago i've updated system , had adapt new situation (loading ddraw.dll) , worked fine. today explored legacy solution uses classes (files) i've changed, i'm stuck above mentioned linking error. i've checked , compared project properties , seam fine. this code directx initialization, "troublesome" code bold. typedef int (__stdcall *directdrawcreatefunc)(guid far* ,lpdirectdraw far* b, iunknown far* c); /* init_directx: * low-level directdraw initialization routine. */ int cdcutils::init_directx(hwnd allegro_wnd) { lpdirectdraw directdraw1; hresult hr; lpvoid temp; hinstance ddraw = loadlibrary("%windir%\system32\ddraw.dll"); if(ddraw== null) { return -1; } _ddrawlib =ddraw; directdrawcreatefunc ddfunc = (directdrawcreatefunc)getprocaddress(ddraw,"dir

post-recieve not invoked when pushing from GIT Bash on Windows -

hey, have post-receive hook enabled on remote repository, works fine when pushing tags\commit upstream linux machine. ( although have sudo when pushing ) . - when pushing windows git client, scripts not invoked. ideas ? thanks, ran are scripts not invoked or not seeing output of script on windows git client? anyway, recommend update client if not latest.

mySQL select one column DISTINCT, with corresponding other columns -

id firstname lastname 1 john doe 2 bugs bunny 3 john johnson i want select distinct results firstname column, need corresponding id , lastname . the result set needs show 1 john , id of 1 , lastname of doe. try query select id, firstname, lastname table group by(firstname)

gwt - Why JSONParser doesn't remove the " from keys and values? -

i have following json-string: {"locale":"de","strings":[{"key":"navigation.search","value":"suchen"}]} i try parse way: // parse response text json string json = response.gettext(); window.alert(json); jsonvalue jsonvalue = jsonparser.parselenient("{\"locale\":\"de\",\"strings\":[{\"key\":\"navigation.search\",\"value\":\"suchen\"}]}"); window.alert(jsonvalue.isobject().get("locale").tostring()); jsonarray jsonarray = jsonvalue.isobject().get("strings").isarray(); (int = 0; < jsonarray.size(); i++) { window.alert(jsonarray.get(i).isobject().get("key").isstring() + " -> " + jsonarray.get(i).isobject().get("value").isstring()); } why there quotes in window.alert(), thought, quotes essential, creating json. by way, json created json.org java-classes: printwriter w =

ios - How to transition UIToolbar with it's parent view -

how can transition 1 uiviewcontroller (with bottom toolbar) 1 (without toolbar), while animation in progress, toolbar moves away first view, meaning toolbar stays in it's initial position of first view? i've seen behaviour in "things" app. just clear, not looking solutions such hiding/showing toolbar inside viewdidappear. so, solution wasn't happy about, @ moment seems one. the point ignore built in toolbar property of uinavigationcontroller, create separate uitoolbar , place inside view controller. // create bar items uibarbuttonitem *flexiblespace = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; nsarray *toolbaritems = [[nsarray alloc] initwithobjects: flexiblespace, nil]; [flexiblespace release], flexiblespace = nil; uitoolbar *customtoolbar = [[uitoolbar alloc] init]; [customtoolbar sizetofit]; [customtoolbar setframe:cgrectmake(0.0, self.view.frame.size.height - self.navig

reporting services - SSRS 2008 R2 - SSRS 2012 - ReportViewer: Reports are blank in Safari and Chrome -

i migrated our reporting services version 2008 server version 2008 r2. in version 2008 reports work fine on safari. new version 2008 r2 reports not show @ all. see parameter section , report blank. same in chrome. according microsoft safari supported if in limited fashion. reports not complex. in fact created report had line on see if show in safari no, report blank well. did make ssrs reports viewable on safari? have mess kind of configuration setting? ultimate solution (works in ssrs 2012 too!) append following script following file (on ssrs server) c:\program files\microsoft sql server\msrs10_50.mssqlserver\reporting services\reportmanager\js\reportingservices.js function pageload() { var element = document.getelementbyid("ctl31_ctl10"); if (element) { element.style.overflow = "visible"; } } note : azzlak noted, div's name isn't ctl31_ctl10 . sql 2012 try ctl32_ctl09 , 2008 r2 try ctl31_ctl09 . if soluti

internet explorer - How to make IE support min-width / max-width CSS properties? -

are these properties not considered standard css? i'm using this, works on chrome 12, ff4, opera 11, , safari 5, on ie9 min-width not respected if width < min-width . <span style="float:left; width:11%; min-width:150px;"> ... </span> edit: little annoyed @ liberal editing , migrating of question, w/e. here's fuller example shows clear difference in ie9 vs other browsers. <html><body> <p style="width: 600px"> <span style="float: left; width: 11%; min-width: 150px">hello.</span> <span style="float: left; width: 11%">world.</span> </p> </body></html> edit 2: noted in kevin's comment below, adding <!doctype html> beginning solves ie issue. if saying true, ie9 deviating form the spec . however, cannot duplicate complaint. using example, ie9 respects min-width if width less 150px per this jsfiddle . edit: note: quirks mode

oop - Which languages allow to change identity of an object (not cast)? -

in this post , brave wants (in c++) downcast object of type base derived type. assuming derived type has no more attributes base , can make sense if you're jealous of methods derived class provides. are there programming languages allow such thing? actually, done without problem in common lisp, , in other lisp dialects clos (common lis object system) ported. use change-class generic function that. clos works multiple dispatch methods, method not tied class or object, it's function chosen in group of similar functions wrt types (or identities) of arguments. when using change-class , can give arguments if creating new instance, , data stored in object remain. here little session shows how works: cl-user> (defclass base () ((name :initarg :name))) #<standard-class base> cl-user> (defclass derived (base) ((age :initarg :age :initform 0))) #<standard-class derived> cl-user> (defvar foo (make-instance 'base :name "jo

opencv - Problem with Python and IP camera -

i'm having problems video stream ip camera have. i'm using opencv images it. here's code have: import sys import cv video="http://prot-on.dyndns.org:8080/video2.mjpeg" capture =cv.capturefromfile(video) cv.namedwindow('video stream', 1 ) while true: # capture current frame frame = cv.queryframe(capture) if frame none: break else: #detect(frame) cv.showimage('video stream', frame) if k == 0x1b: # esc print 'esc pressed. exiting ...' break actually, thing works, takes time display images. i'm guessing it's because of error ffmpeg. [mjpeg @ 0x8cd0940]max_analyze_duration reached [mjpeg @ 0x8cd0940]estimating duration bitrate, may inaccurate i'm not python expert appreciated! first, mjpeg relatively simple video format. if read ip camera's manual, it's can find how display video in browser bit javascript code. in fact, if open link of http://prot-on.dyndns.org:8080

Retrieve latitude and longitude of a draggable pin via Google Maps API V3 -

i explain. managed have draggable pin on map. want retrieve coordinates of point , put them 2 fields: latitude , longitude. these coordinates later send sql table via php. here an example of intend do, instead of several pins, it's 1 , it's draggable. problem is: i'm not able display coordinates of initial point. , of course when user moves pin, want coordinates change in fields. hope made myself clear. did wrong? should use geocoding service? here goes js: <script type="text/javascript"> var map; function initialize() { var mylatlng = new google.maps.latlng(40.713956,-74.006653); var myoptions = { zoom: 8, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var marker = new google.maps.marker({ draggable: true, position: mylatlng, map: map, title: "your location" }); google.maps.event.addlistene

javascript - how to center div in middle of browser viewport like google -

i have search website needs have search bar , logo centered vertically , horizontally in index page items on page. what best , effective way implementing this for css-only approach check out fiddle. http://jsfiddle.net/jeffrod/nfths/ it requires width , height of center box known. positions top left of box in middle , then, using margins, shifts center of box @ center of page.

iphone - Getting an NSArray of a single attribute from an NSArray -

i facing regular scenario. i have nsarray has object of custom type, person. person class has attributes: firstname, lastname , age. how can nsarray containing 1 attribute nsarray having person objects? something like: nsarray *people; nsarray *firstnames = [people getarrayofattribute:@"firstname" andtype:person.class] i have solution of writing loop , fill in firstnames array don't want that. nsarray handle using kvc nsarray *people ...; nsarray *firstname = [people valueforkey:@"firstname"]; this give array of firstname values each entry in array

json - jqGrid Access Extra Information -

i have dynamically created jqgrid custom formatter. need able access information not in grid column within formatter. problem rowobject seems contain information columns , nothing else, though json data has attribute. my json looks like: {"rows": [ {"cell":["637","alice","test","01\/01\/1980",""],"id":"637","patient_id":"637"}, ... {"cell":["635","alice","test","01\/01\/1980",""],"id":"635","patient_id":"635"}, ], "form_id":"3", "records":"35", "total":2, "goto_patient_sidebar":"1", "totalrecords":"35", "dynamicfilters":"", "listname":"patients", "page":1, "recordsreturned":25, "col

javascript - send mail form not sending mail -

i have form pops when user clicks link , sends email address of choice. form looks great, email isn't getting sent... <a href='#emailpopup' id='sendmessage'><img src="images/email.jpg"></a> <div id="tellfriend" class="contact_form"> <a class="close" href="#close" >close</a> <form id='tellafriend_form' method="post" action="http://naturesfootprintinc.com/sendmail.php"> <label for="name">your name: </label> <input class="std_input" type="text" id="name" name="name" size="40" maxlength="35" value="" /> <label for="to">friend's email: </label> <input class="std_input" type="text" id="to" name="to" size="40" maxlength=&quo

java - How to decode the value encoded as one*100 + two*10 + three? -

how values one , two , three back? following approach correct? looks no. int encodedvalue = one*100 + two*10 + three; // following decryption part of procedure int 1 = encodedvalue / 100; int 2 = encodedvalue / 10; int 3 = encodedvalue % 10; assuming two , three in range 0-9 (otherwise have ambiguity) want: int 2 = (encodedvalue / 10) % 10; ... otherwise gets ten times one value added it.

Java: random integer with non-uniform distribution -

Image
how can create random integer n in java, between 1 , k "linear descending distribution", i.e. 1 likely, 2 less likely, 3 less likely, ..., k least likely, , probabilities descend linearly, this: i know there dosens of threads on topic already, , apologize making new one, can't seem able create need them. know using import java.util.*; , code random r=new random(); int n=r.nextint(k)+1; creates random integer between 1 , k , distributed uniformly. generalization: hints creating arbitrarily distributed integer, i.e. f(n)=some function , p(n)=f(n)/(f(1)+...+f(k)) ), appreciated, example: . this should give need: public static int getlinnearrandomnumber(int maxsize){ //get linearly multiplied random number int randommultiplier = maxsize * (maxsize + 1) / 2; random r=new random(); int randomint = r.nextint(randommultiplier); //linearly iterate through possible values find correct 1 int linearrandomnumber = 0; for(i

python - Simple string match -

i want simple string match, searching -front- of string. there easier ways maybe builtin? ( re seems overkill) def matchstr(ipadr = '10.20.30.40', matchip = '10.20.'): if ipadr[0:len(matchip)] == matchip: return true return false def matchstr(ipadr = '10.20.30.40', matchip = '10.20.'): return ipadr.startswith(matchip)

vb.net - Recognizing new or already known document with VSTO -

i've never worked vsto , i've read kinds of stuff it. ask theoretical question. i'm trying make addin should (using buttons in it's own ribbon tab) upload document website (it's slideshare). problem file may uploaded , user may trying update it. so need way tell if file has been uploaded. know prediction can't 100% accurate, that's why i'm going ask user dialog, need clever alert user if file may uploaded. this assumption can client-side only, database of sort (in addin itself). thought of recording file's name , based on can decide if file new or it's uploaded. do have other ideas? maybe there's more clever way this? ps. working on office 2010 latest version of vsto in vs 2010. main .net language vb samples in c# more welcome (if have ones). what i'd in case add document variable or document property value of guid. then when push file, server extract property, guid , perform lookup see if doc there. at least, tha

search string inside a word in java -

i want search word inside string : example let string "thisisfile.java" , let want search "file.java" or "isfile" this sql 'like' query unfortunately not getting string database. please suggest me solution this. thanks there's variety of ways of achieving , method choose depend on complexity of queries. simple plain symbol/word match string class provides contains method takes single parameter, string search - , returns true if occurs within search string. bool containsfile = mystring.contains("file");

linux - FTP command to put a directory to server from local system -

put filename put file cureent directory in server. which command have use move entire folder/ directory?? mput * ftp can't put directly directory trees, files.

join - horizontal UNION ALL -

i have 2 tables , need select 1 column each of them. must done in single query. news 2 columns ordered right way , both contain same number of rows. now, know join 2 tables rowid, slow has comparison. in case not necessary... need more horizontal union concatenate 2 columns of equal length. is possible in sqlite 3? thanks. table1: | timestamp | field1 | field2 | ... | 12345678 | 000000 | 000000 | ... | 00154789 | 000000 | 000000 | ... table2: | temperature | | 1000000000 | | 2000000000 | required select output | timestamp | temperature | | 12345678 | 1000000000 | | 00154789 | 2000000000 | query : select timestamp, temperature table1 inner join table2 on table1.rowid = table2.rowid; this takes ~0.75s in testing app. when 2 separate selects , join outputs later in program takes ~0.4s, not convenient. fastest way (~0.23s) have both columns in 1 table, wasteful have multiple versions of table2 share same timestamps. sqlite supports union all .

android - How to set image in ImageView to right proportions -

Image
look @ picture below. i'm loading image sdcard code belove. i cannot picture automatically fill imageview. set background color green highlight problem. have tried many android:scaletype center , fit_xy but. im using insamplesize = 8 how can imageview automatically scale image in right hight/width proportions , fill screen also thing, see exittext , button placed above imageview(i think). want them under , not block imageview. maybe misunderstand android layout technical. drawview.java public class drawview extends imageview { private context ctx; public drawview(context context, attributeset atts) { super(context, atts); this.ctx = context; } @override protected void ondraw(canvas canvas) { string filepath = environment.getexternalstoragedirectory().tostring() + "/ptppservice/163693fe-7c48-4568-a082-00047123b9f1.2.imag2200.jpg"; bitmapfactory.options options = new bitmapfactory.options(); options.insamplesize = 8; bitmap bit

android - Overridden Class Only Offers Static Methods -

i have class overrides textview if try use of member functions of either class or textview error message in eclipse stating "cannot make static reference non-static method ##member function## type view". ##member function## method calling i.e. setlayoutparams(viewgroup.layoutparams). if in suggestions dialog static methods offered. i have tried cutting class down too; import android.widget.textview; public class myclass extends textview { public myclass(context context) { super(context); } } but still same errors. thanks in advance, mark you're doing textview.method() calls instead of textview.method() textview instance of textview. error not match post title @ -- it's opposite.

c# - How would you approach this simple string parsing problem? -

"\n \n expected:\n \n \n q4\n \n \n 2011\n \n " from string, need following: "expected q4 2011" i've tried following , no dice: mystring.trim().replace("\n", ""); i following (the massive whitespace intentional , not site formatter issue. in fact returned.) "expected: q4 2011" replace white space blocks single space: mystring = regex.rep