Posts

Showing posts from April, 2010

time complexity - What sorting technique does merge sort use while merging -

at last 1 step of merge sort have 2 sorted lists , trying combine them 1 sorted list, how logic go? this naive mind came with: take each element of list #1 , compare each element of list#2 , find place in list #2. insertion sort. but not how happens because gives me complexity of o(n^2). merge sort o(nlogn). how final step happens? it uses merge sort. merge sort doesn't have separate sorting algorithm, sorting algorithm. so original lists sorted, smallest element @ beginning. compare , b. take lesser of 2 , add end of result list. repeat until both source lists empty.

c# - Multiple parameters in seed lambda expression -

i utilizing seed() method populate database. trying pre-populate 1 table data based on 2 keys, not one. for example, doing elsewhere , working fine: foreach (var drug in drugs) { context.drugs.addorupdate( d => d.orderid, drug ); } is possible following? foreach (var pd in patientdrugs) { context.patientdrugs.addorupdate( (p => p.dispensedate && p => p.drugid), pd ); } did try this? foreach (var pd in patientdrugs) { context.patientdrugs .addorupdate(p => new { p.dispensedate, p.drugid }, pd); }

c# - .Net 4.5 System dlls are missing after installing windows8 SDK and restart -

Image
i working on mvc3 project in visual studio 2012 targeting 4.5. right until installed windows8 sdk developing apps windows8 last night.after restarting computer, mvc3 projects have missing dlls.if reference 4.0 version fine again missing classes , have changed targeting .net version 4.0 not want @ moment. this picture showing missing dlls.i tried find in c:\program files (x86)\reference assemblies/microsoft... not find 4.5 missing dll. os: windows 7 update: now have found 4.5 dlls in c:\program files (x86)\reference assemblies\microsoft\framework.netcore\v4.5 problem every visual studio project template.there aslo problem, system.linq have refrenced using system.linq not recognize namespace.can suggest me tool or fix /update patch ? update 2: visual studio removal , re installation didn't ,it still showing warning errors on dlls.

python - How do I display sentences from a website? -

i decided make little project learn how use mechanize. goes urbandictionary, fills in word 'skid' inside search form , press submit , prints out html. what want find first definition , print out. how go , that? this source code far: import mechanize br = mechanize.browser() page = br.open("http://www.urbandictionary.com/") br.select_form(nr=0) br["term"] = "skid" br.submit() print br.response().read() here's definition stored: <div class="definition">canadian definition: commonly used refer stopped evolving, , bathing, during 80&#x27;s hair band era. can found wearing ac/dc muscle shirts, leather jackets, , sporting <a href="/define.php?term=mullet">mullet</a>. term &quot;skid&quot; in part derived &quot;skid row&quot;, both band enjoyed term refers to, address. see <a href="/define.php?term=white%20trash">white trash</a> , <a href=&quo

angular routing - AngularJS routeProvider when hash sign is present -

i have app hosted on iis. app url http://localhost/tool when load page typing in url, url path changes http://localhost/tool#/tool i don't have in $routeprovider config. process url request like, http://localhost/tool#/request/:param1/:param2 or if possible http://localhost/tool#/request?param1=value&?param2=value how write $routeprovider configuration? further in situation, user needs direct url state of page user may not start http://localhost/tool start http://localhost/tool#/request/:param1/:param2 . please help. i think possible have url localhost/tool#/request?param1=value&?param2=value : angular.module('myapp'). config( ['$routeprovider', function($routeprovider){ $routeprovider. when('/tool', {templateurl: './view/partial/tool_list.html', controller: toollistctrl}). when('/tool/:param1/:param2', {templateurl: './view/parti

python - Multiple sequence comparison of arbitrary string with oriented characters -

the core problem is: i looking algorithm calculate maximum parsimonious distance between set of strings. distance mean similar damerau–levenshtein distance i.e. minimal number of deletions, insertions, substitution , transposition of characters or adjacent characters blocks. instead of regular strings want investigate strings oriented characters. thus, string like: (a,1) (b,1) (c,1) (d,1) and possible derivatives be: (a,1) (c,0) (b,0) (d,1) (a,1) (c,1) (b,1) (d,1) (a,1) (b,0) (c,0) (d,1) where a,b,c,d character identities , 1 = forward , 0 = reverse . here, derivative 1. have distance 2, since cut out block bc , re paste inverted (1 cut, 1 paste). derivative 2. have 2 well, since may cut out c , re paste in front of b (1 cut, 1 paste) whereas number 3. require 4 operations (2 cuts, 2 pastes) transformed. analogous, deletion or insertion of blocks yield distance 1. if define (x,0) , (x,1) 2 different non oriented characters (x0, x1) possible x, example 3.

html - CSS - How to working with multi-level menu by simple -

Image
i have multi-level menu like i want menu has same background (#5b740d see) has same active background (red see) has same hover background (red see) and 3 above option menu , sub-menu but code complex. here example code hover /* hover: can using simple selector make same background */ .menu li:hover { background: red; } .menu li li ul li a:hover { background: red; } .menu li ul li:hover { background: red; } i css on internet it's complex change way ( but still complex :( plz me make simple ). but bug: when hover item (2) in picture bellow item (3) hover? plz simplified css code 3 option above (i don't understand complex code :( ) , me fix bug thank. here code http://jsfiddle.net/swf6w/ there's no way make more 'simple', there little superfluous markup or definitions in code, don't understand appeal make more simple. you can fix red hover on child elements specifying direct descendent selector on li:hover a selec

Distance between two canvas co-ordinates in javascript -

i'm acquainted basic math , know equations, when try implement them in canvas fail. here's relevant code: function distance(one,two){ var a, b if(one[0] > one[1]){ = one[1] - one[0] }else{ = one[0] - one[1] } if(two[0] > two[1]){ b = two[1] - two[0] }else{ b = two[0] - two[1] } var c = a^2 + b^2; return math.sqrt(c); } radius = distance([centerx,e.clientx], [centery,e.clienty]) context.fillcircle(centerx, centery, radius, "white"); here's code in action as can see, circle far short , don't know why... when remove sqrt, becomes out of whack quickly. ^ not think does. js> 8^2 10 js> math.pow(8,2) 64

How use "LIKE" and "%" to check similarity to variable in android(Java code) -

i working on android app using java, need query database in java code check if userinput(variable) statement contain words in sqlite database using like in query , rowquery method in java code, i used code did not work: cursor = db.rawquery("select shompet sentence " + column + " '%" + newmessage + "%'", null); newmessage variable(userinput) i read similar topics either not answer or complicated. in expression 'hi' '%hi there%' , not possible find any characters replace % wildcards strings match. you need comparison other way around, i.e., 'hi there' '%hi%' : db.rawquery("select shompet sentence" + " ? '%' || " + column + " || '%'", new string[] { newmessage });

php - Retrieving form field and display value in fancybox -

i trying create basic form 1 text field. when user inputs code text field. when click submit have iframe pop url + text field value. everything looks me setup correctly fancybox loading screen never goes away , iframe never shows. this sample of not working: <form id="form" onsubmit="fancybox.iframe('http://www.regonline.com/eventinfo.asp?eventid=' + document.form.event.value);return false;" autocomplete="off" style="height: 100%;" enctype="multipart/form-data" action="/contact/tabid/59/default.aspx" method="post" name="form"> <input type="text" name="event"> </form> <?php $eventid = $_post['event']; echo '<a class="fancybox fancybox.iframe" href="http://www.regonline.com/eventinfo.asp?eventid='. $eventid .'">submit</a>'; ?> this work opens window , cannot working fancybox

How do you configure the XCode Jenkins plugin to run tests? -

the instructions running tests jenkins xcode plugin set test target (which i've done), sdk (which i've done) , configuration (which tried nothing, debug, , test). however keep getting "...is not configured running". how run tests? this output: + xcodebuild -workspace /users/mydir/.jenkins/jobs/mytests/workspace/folder/myworkspace.xcworkspace -scheme mytestscheme clean xcodebuild: error: failed build workspace myworkspace scheme mytestscheme. reason: scheme "mytestscheme" not configured running. if within xcode mytestscheme if choose product/run same error message, if choose product/test test code executes successfully. output sucessful run in xcode is: 2013-08-28 11:10:25.828 otest[65917:303] unknown device type. using uiuserinterfaceidiomphone based on screen size test suite 'multiple selected tests' started @ 2013-08-28 18:10:26 +0000 test suite '/users/mydir/library/developer/xcode/deriveddata/myworkspace-ctngidolzdhijvbym

ios - ContainerView with multiple embed segues -

is there way have single containerview multiple embed segues? aim containerview hold few different viewcontrollers depending on buttons have been pressed; 1 going visible @ time. want use embed segues in interface builder storyboards automatically shown @ same size containerview. i realise can manually resize other viewcontrollers in interfacebuilder, want automatic sizing provided embed segue. if way of doing available, fine too. not having views load on viewdidload fine - mentioned earlier, shown viewcontroller can change depending on buttons pressed. no, there no way have multiple embed segues 1 container view. 1 way setup in ib, make embedded controller uitabbarcontroller (with tab bar hidden). can have many controllers in tabs want, , switch them in code using selectedindex property of uitabbarcontroller.

c# - is ApiController capable of being added as a service reference? -

is mvc4 apicontroller capable of being added service reference? hope avoid creating redundant wcf service non-web applications can access api. tried referencing 1 of url's service reference console app project , got error: there error downloading 'http://mypcname/webservices.data/api/controllername/get?epid=123&supressresults=false/_vti_bin/listdata.svc/$metadata'. the request failed http status 400: bad request. metadata contains reference cannot resolved: 'http://mypcname/webservices.data/api/conrollername/get?epid=123&supressresults=false'. the http request unauthorized client authentication scheme 'anonymous'. authentication header received server 'negotiate,ntlm'. remote server returned error: (401) unauthorized. if service defined in current solution, try building solution , adding service reference again.

algorithm - Logic challenge: sorting arrays alphabetically in C -

i'm new programming, learning c. i've been working @ problem week now, , can't seem logic straight. straight book i'm using: build program uses array of strings store following names: "florida" "oregon" "califoria" "georgia" using preceding array of strings, write own sort() function display each state's name in alphabetical order using strcmp() function. so, let's have: char *statesarray[4] = {"florida", "oregon", "california", "georgia"}; should nested loops, strcmp(string[x], string[y])... ? i've hacked , hacked away. can't wrap head around algorithm required solve efficiently. appreciated!!! yes, can sort using nested loops. after understand how strcmp() works should straight forward: strcmp(char *string1, char *string2) if return value < 0 indicates string1 less string2 if return value > 0

syntax - PHP Switch multiple parameters -

is there way of making more organized? if (!isset( $par2 ) && !isset( $par3 )) { $where = "lvlone = '".$par1."'"; } elseif(isset( $par2 ) && !isset( $par3 )) { $where = "lvlone = '".$par1."' , lvltwo = '".$par2."'"; } elseif(isset( $par2 ) && isset( $par3 )) { $where = "lvlone = '".$par1."' , lvltwo = '".$par2."' , lvlthree = '".$par3."'"; } concatenation: $where = "lvlone = '{$par1}'"; if(isset( $par2 )) { $where .= " , lvltwo = '{$par2}'"; } if(isset( $par3 )) { $where .= " , lvlthree = '{$par3}'"; } concatenation ternary: $where = "lvlone = '{$par1}'"; $where .= isset($par2)?" , lvltwo = '{$par2}'":''; $where .= isset($par3)?" , lvlthree = '{$par3}

PHP Sessions lost on url redirect -

i'm using php sdk box api. i've been desperately trying send variables used search in box. i've found once page redirected box api after login session variables (or variables @ have been sent or assigned before authentication) lost. i've had session_start() @ beginning of each page i've tried. any idea on how can keep variables in session? i don't precisely know answer question, might consider saving session info in authorization url's state variable.

hevc - Mixtion of Debug exe and release exe for encoder and decoder -

this hevc encoder , decoder have ** encoder , decoder in debug mode ** encoder , decoder in release mode i know release mode optimize something. can use debug encoder , release decoder?(i have not verified this) how release encoder , debug decoder? (i try this, ok) i guess both should ok, still want know why yes or why not in theoretical level. not entirely sure asking if e.g. @ linux makefile, you'll see this: debug: $(make) -c lib/tlibvideoio debug mm32=$(m32) $(make) -c lib/tlibcommon debug mm32=$(m32) $(make) -c lib/tlibdecoder debug mm32=$(m32) $(make) -c lib/tlibencoder debug mm32=$(m32) $(make) -c lib/tappcommon debug mm32=$(m32) $(make) -c app/tappdecoder debug mm32=$(m32) $(make) -c app/tappencoder debug mm32=$(m32) $(make) -c utils/annexbbytecount debug mm32=$(m32) $(make) -c utils/convert_ntombit_ycbcr debug mm32=$(m32) release: $(make) -c lib/tlibvideoio release mm32=$(m32)

iphone - Force landscape for one view controller ios -

i've looked @ several answers questions similar none of answer worked. have app need portait except 1 photo viewer have. in supported orientations section of targets menu have portrait. how force 1 view landscape. being pushed onto stack nav controller i'm using storyboards control that. since answer seems hidden in comments of question , since arunmak's answer quite confusing, i'll offer found out: all had add function custom uiviewcontroller subclass view: - (nsuinteger)supportedinterfaceorientations { if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiompad) { // ipad: allow orientations return uiinterfaceorientationmaskall; } else { // iphone: allow landscape return uiinterfaceorientationmasklandscape; } } note project needs allow orientations (that is: portrait, landscape left, landscape right - never upside down on iphone!). if want limit or views portrait, need implement abov

clientscript - How to override the service now's email notification onclick event -

i have requirement like, when click email notification link in service now, system should check particular field not null or null, if not null service now's email notification window should open, otherwise 1 alert box should come pls enter field first as long ok w/ validation being done client side modify onclick event on email notification link , add additional function check value of field , if not null, call original email onclick function. prototype available in servicenow forms clients side , provides method update attributes on elements . you need modify onclick function on element id='email_client_open', add new onclick function check field in question populated , if call original function 'emailclientopen(this, 'incident')' appropriate parameters.

How to control allocations in Objective C ARC project iPhone sdg -

i have written code in objective c arc project working fine after running project 20-25 project crash. have tested project on xcode instrument there found no leaks in instrument have observed live bytes continually increasing. there way handle or there way remove , free allocated memory of project. the common cause of retain cycles. retain cycles happen when have 2 objects , b hold strong references each other. definition, object won't released arc until reference count 0. therefore, can't delete unless delete b first, , can't delete b until delete a. solve this, change 1 of strong references weak one. typically, want container class hold strong reference, , child class hold weak reference container. here examples , more detailed information: retain cycle in arc advanced memory management programming guide (look @ "use weak references avoid retain cycles" section)

html - How can I ignore inherited styles without using "!important"? -

i don't know if it's possible, know how can ignore inherited css styles in new class without using !important each one? my html code: <div class="text"> <h2>title</h2> <span>date</span> <p>text here...</p> <div class="sub-text"> <p>more text!</p> <span>thanks!</span> </div> </div> css: .text {width:100%; float:left;} .text h2 {font-size: 20px;} .text span {font-size: 12px; font-style: italic;} .text p {font-size: 12px;} .sub-text {width: 100%; float: left;} .sub-text p {i want ignore inherit class without use !important} .sub-text span {i want ignore inherit class without use !important} if want target span , h2 , p within .text , not within .sub-text should use selector > like this: .text > h2 { font-size: 20px; } that target h2 direct child of .text . also check http://www.w3schools.com/cssref/css_selector

javascript - Unexpected call to method or property access - appendChild() -

i have created bookmarklet executes below code, adding css styling page. works on tried sites in chrome , firefox, fails sites on ie. it's same sites fail. the fourth line fails "unexpected call method or property access" sites, on ie. var head = document.getelementsbytagname('head')[0]; var style = document.createelement('style'); style.type = 'text/css'; style.appendchild(document.createtextnode("")); head.appendchild(style); two sites fail on ie 10: http://www.momswhothink.com/cake-recipes/banana-cake-recipe.html http://www.bakerella.com/ i think problem line: style.appendchild(document.createtextnode("")); here inserting text node style element, according html specification not allowed, unless specify scoped attribute on style. check specification of style here ( text node flow content). you can find ways create style element in crossbrowser way here .

Communicating between iOS and Android with Bluetooth LE -

i've got working app using corebluetooth communicate between ipad (central) , iphone (peripheral). have 1 service has 2 characteristics. have nexus 7 running latest android 4.3 btle support. android bit late jump on btle bandwagon appears approaching how ios did, support acting central peripheral mode coming in later version. can load sample android btle app , browse nearby peripherals. iphone advertising peripheral can see value cbadvertisementdatalocalnamekey in list of nearby peripherals on android side. can connect iphone , bluetooth symbol turns light gray black when connection made. connection lasts 10 seconds , disconnects. on android side i'm supposed see list of available services , characteristics appear upon connection. i've proved android code setup correctly because can connnect ti cc2541dk-sensor hardware have , services , characteristics listed upon connecting it. i've spent last few days troubleshooting issue no success. problem can't determine

What 8-bit encodings use the C1 range for characters? (x80—x9F or 128—159) -

wikipedia has listing of x80—x9f "c1" range under latin 1 supplement unicode. range reserved in iso-8859-1 codepage. i'm looking @ file of strings, of within 7-bit ascii range except few instances of \x96 looks dash be, such middle of street address. i don't know if other characters in c1 range might show in data, i'd know if there's correct way read file. there 8-bit encodings use x80 through x9f character data instead of terminal control characters? there large number (potentially infinite number) of 8-bit encodings assign graphic characters or bytes in range 0x80 0x9f. several encodings defined microsoft have u+2013 en dash “–” @ byte position 0x96, , character conceivably appear in street address, between numbers. on other hand, e.g. macroman has letter “ñ” @ position 0x96, , appear within street name in spanish, example. for rational analysis of situation, should inspect data whole, possibly using filter finds bytes outside ascii r

winforms - print dynamically generated checkbox selected rows from datagridview to crystal report on another form c# -

Image
i have dynamically added checkboxes each row in datagridview (form1)and trying generate crystal report on new form (form 2) rows checkbox checked. my code on form1 button click private void btn_print_click(object sender, eventargs e) { //im trying insert selected rows in datatable datasource crystal report datatable table = new datatable(); int = 1; foreach (datagridviewrow row in datagridview1.selectedrows) //datagridview1.selectedrows[0].cells["select"].value) { (int j = 1; j < datagridview1.columncount; ++j) { table.rows[i][j] = row.cells[j].value; } ++i; } if (cb_reptype.selecteditem.tostring() == "individual") { //here im specifying path new form2 string path = table.tostring();//datagridview1.selectedrows[1].cells["table"].value.tostring(); form2 f2 = new form2(path); //reportdocument crystal = new

multithreading - Thread Interrupt in java -

i have following questions, if interrupt thread in java, process running 15 minutes, stop process, stop methods or finish process,and not allow others continue in line? i have "thread" call method comparison based "access" , "postgres" after insert in postgres, if want stop thread called action, succeed stop process, or wait finish? it not stop thread unless methods executing in willing terminate when receive "interrupt" signal. methods throw interruptedexception fall category. of course, methods in call chain need cooperate in 1 way or another. if code not call "interruptable" methods or has sections don't call them long periods, make them check flag thread.isinterrupted() periodically, , terminate clean , gracefully if ever becomes true . same thing if ever receive (and catch, should) interruptedexception s. your question can improved, though, if intent more specific. explain how "thread interrupt&quo

Javascript disabled inside iframe -

i have iframe points facebookauthentification. makes redirect via javascript. actually nothing happens , looks javascript not executed. sandbox mode not set , doesn't work either when sandbox mode set execute scripts. the javascript redirect works outside iframe nice there js code inside iframe: <script type="text/javascript">self.location.href="redirect.php"</script>

c++ - I'm having issues getting the qwt widget to work correctly with Qt-Creator -

i'm having issues getting qwt 6.1.0 work correctly qt-creator 5.1.0. works correctly when launch stand alone version of qt-designer , compiles , runs correctly when use qt-creator. designer built qt-creator not display qwt widgets correctly on forms nor give me option add new qwt widgets. i'm using qt creator 5.1.0 windows 64-bit (vs2012 opengl). i've downloaded , compiled qwt 6.1.0 aforementioned qt-creator, opening qwt.pro file , compiling it. once compiled used 'nmake' , 'nmake install' commands visual studio command prompt directed in qwt instructions ( http://qwt.sourceforge.net/qwtinstall.html ). copied qwt_designer_plugin.dll c:\qt\qt5.1.0\tools\qtcreator\bin\plugins\designer\ , c:\qt\qt5.1.0\5.1.0\msvc2012_64_opengl\plugins\designer\ directories. does have suggestions? can manually launch qt-designer , compile qt-creator, kind of annoying have switch , forth , not able use designer bundled qt-creator. edit #1: i've set path envir

sql server - Inserting a pdf file to SQL table using SQL -

i trying insert pdf file sql table (varbinary column) create table pdftest(pdfdata varbinary(max)) declare @filepath varchar(100) set @filepath = 'c:\pdfsample.pdf' insert pdftest (pdfdata) select * openrowset(bulk @filepath, single_blob) blob however gives error incorrect syntax near '@filepath'. none of following assignment works set @filepath = 'c:'\pdfsample.pdf' set @filepath = 'c:\\pdfsample.pdf' but following syntax works insert pdftest (pdfdata) select * openrowset(bulk 'c:\pdfsample.pdf', single_blob) blob just wondering how @filepath can used in insert statement? thank you i think here variable name not getting resolved. try using variable name in dynamic sql. declare @sql varchar(max) set @sql='insert pdftest (pdfdata) select * openrowset(bulk'+ @filepath+', single_blob) blob' exec @sql

PHP Regex to find first n characters and finish it until end of sentence -

i new in php , sorry if answered here, searched many posts unsuccessful hence asking. i have large text block , wants output such should return first 250 characters , finish till end of sentence. $output= preg_replace('/([^?!.]*.).*/', '\\1', substr($string, 250)); can please me in right direction? thanks. this works: $output = preg_replace("/^(.{250})([^\.]*\.)(.*)$/", "\\1\\2", $text); the regex has 3 parts: ^ # beginning of string (.{250}) # 250 characters of ([^\.]*\.) # number of non-periods, followed single period (.*) # $ # end of string then preg_replace replaces entire string first 2 parts. input: lorem ipsum dolor sit amet, consectetur adipiscing elit. nulla pharetra dignissim mauris, pretium viverra justo tempus at. mauris nisl lectus, accumsan pretium ipsum ac, fringilla vehicula tellus. proin ante mauris, consequat sed mollis id, euismod ac turpis. mauris tellus massa

ruby on rails - Problems Using routing-filter beta version 0.4.0.pre -

i using 0.4.0.pre version of routing-filter rails 4 @ suggestion of person posted version in rubygems. not find version when search on rubygems website. found out when posted comment on existing issue in github. https://rubygems.org/gems/routing-filter/versions/0.4.0.pre i finding differences between version , 1 use in rails 3 applications. believe latest version 0.3.1. gem locale included in urls , in debug info @ bottom when running localhost expected. when use 0.4.0.pre version locales not show in urls or debug info. have links @ top of header section person can select locale. when 1 of links clicked locale appears in url. when click link (text or icon) locale disappears locale set in cookie (a supposed no no keep now). translations correct selected locale unless special in links person know 1 clicked, no 1 know locale. problem because setting locale files , of them in english until able translations other languages. here code have in both applications in applicat

java - Trouble reading BufferedImage -

i'm having odd problem. have game of sorts image bounces around screen in 'darkness' (black rect ) , mouse cursor represents flashlight shining through dark (subtracts oval). now have 1 .png image , 1 .wav sound file. have them both in "resources" folder in project folder , access them via filepaths "resources/myimage.png" , "resources/mysound.wav" . everything works fine when run program in eclipse (using kepler btw); image shows fine, , sound plays when commanded to, export jar , run, shows program name few seconds if active program, shortly after quits/crashes. open terminal , run java -jar /users/myusername/desktop/myprog.jar garners same result crash log in terminal. reads: aug 23, 2013 4:10:02 pm com.spotlight.testpane <init> severe: null javax.imageio.iioexception: can't read input file! @ javax.imageio.imageio.read(imageio.java:1301) @ com.spotlight.testpane.<init>(testpane.java:62) @ com.spotl

regex - Why is Bash pattern match for ?(*[[:class:]])foobar slow? -

i have text file foobar.txt around 10kb, not long. yet following match search command takes 10 seconds on high-performance linux machine. bash>shopt -s extglob bash>[[ `cat foobar.txt` == ?(*[[:print:]])foobar ]] there no match: characters in foobar.txt printable there no string "foobar". the search should try match 2 alternatives, each of them not match: "foobar" that's instantenous *[[:print:]]foobar - should go this: should scan file character character in 1 pass, each time, check if next characters [[:print:]]foobar this should fast, no way should take millisecond per character. in fact, if drop ?, is, do bash>[[ `cat foobar.txt` == *[[:print:]]foobar ]] this is instantaneous. second alternative above, without first. so why long?? as others have noted, you're better off using grep . that said, if wanted stick [[ conditional - combining @konsolebox , @rici's advice - you'd get: [[ $(<f

java - Anything wrong with modify an object inside a loop? -

public collection<queuemetrics> getallgatewayqueuemetricscurrent(string keywords) { queuemetrics qminput = null; queuemetrics qmimport = null ; queuemetrics qmreport = null ; arraylist<queuemetrics> metrics = new arraylist<queuemetrics>(); (string keyword : keywords.split(",")){ consoleservicembean console = getconsoleservice(keyword); populatemessagecountstr(qminput, keyword, console, "input"); populatemessagecountstr(qmimport, keyword, console, "import"); populatemessagecountstr(qmreport, keyword, console, "report"); } metrics.add(qminput); metrics.add(qmimport); metrics.add(qmreport); return metrics; } private void populatemessagecountstr(queuemetrics qmetrics, string keyword, consoleservicembean console, string type) { queuemetrics tempmetric = console.getgatewayqueuemetricscurrent(type, keyword); if( qmetrics == null ){

javascript - Set an existing column to tooltip in google visualization api? -

is possible set existing column used html tooltip bar chart in google api without having perform following: data.addcolumn({type:'string',role:'tooltip'}); then adding tooltip specific fields after converting data datatable? there a: data.setcolumn(2, {type:'string',role:'tooltip'}) such dont have adda new one? such function exist? my data this: [ ["name", "number", "tooltip"], ["james", 1, "tooltip james"], ["kyle", 2, "tooltip kyle"] ] use datatable#setcolumnproperty method set role: data.setcolumnproperty(2, 'role', 'tooltip');

c# - Widening Conversion between Reference types -

i know in widening conversion, destination data type can hold value provided source data type. can understand when convert value type, can't between reference types. question arises follows scenario: public class person { public string name { get; set; } } public class employee : person { public string surname { get; set; } } static void main(string[] args) { employee emp = new employee { name = "elvin", surname = "mammadov" }; person prs = emp; } as shown, person class ancestor class of empoyee . in previouse code, create reference of emplyee class, , convert employee object person. @ point, lose surname data field , value. i want know: is countary can hold value expression? why conversion reference type direct or indirect ancestor class or interface widening conversion? thanks reply it called 'widening conversion' because you're becoming less specific regard references type, you're widening set of

jquery rollover mouse fade image -

i have jquery script replace image when rollover wit mouse on image. i want changed fading. what need do? thanks! <img src='images/dogysitter_s.png' alt='' id='first' /> <script type='text/javascript'> $(document).ready(function(){ $("#first").hover( function() {$(this).attr("src","images/dogysitter_c.png");}, function() {$(this).attr("src","images/dogysitter_s.png"); }); }); </script> this fade element out, swap images, , fade element in (animating opacity avoid issues mouseleave being triggered when element fades out) : $(document).ready(function(){ $("#first").on({ mouseenter: function() { $(this).animate({opacity: 0}, 400, function() { $(this).attr('src', 'images/dogysitter_c.png') .animate({opacity: 1}, 400); }); },

php - Count the number of rows in MySQL table with criteria depending on other table -

i've got 2 tables: content: id access 1 3 2 5 3 9 viewlevels: id group 1 [10,12,15] 2 [8,12,11] 3 [9,10,5] the access field in content related id field in viewlevels. i select rows in viewlevels depending on current user group. example, if group = 10, query select rows 1 , 3. if group 12, select rows 1 , 2, etc. i'm using following query: $query="select id #__viewlevels rules '%$group%'"; my challenge count number of rows column id in table content access matches selected id's above query on table viewlevels. i tried following code returning error: undefined variable: nartigos $query="select count(id) #__content access in (select id #__viewlevels rules '%$group%')"; if ($stmt = mysqli_prepare($link, $query)) { /* execute query */ mysqli_stmt_execute($stmt); /* store result */ mysqli_stmt_store_result($stmt); $nartigos=mysqli_stmt_num_rows($stmt); /* close statement

php - uploading multiple files, renaming with form data -

ok first off, i'm new here, if i'm not posting correctly, please let me know. did search extensively on site, did not find issue. i have php form , uploader should upload multiple files , rename files (add name & date original file name) according response in name field of form, , date of upload. everything works except: 1 file uploads, not multiple files. while writing this, did work, i've messed recently. can tell me went wrong? thanks. here code form: <?php // make note of current working directory relative root. $directory_self = str_replace(basename($_server['php_self']), '', $_server['php_self']); // location of upload handler $uploadhandler = 'http://' . $_server['http_host'] . $directory_self . 'upload.processor.php'; // max file bytes (2mb) $max_file_size = 2097152; // echo ?><!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">

why are strings encoded in utf-8 if the default encoding is ascii? - python -

in python, when import sys , type: >>> sys.getdefaultencoding() >>> 'ascii' why string automatically encoded utf-8? >>> = 'ö' >>> >>> '\xc3\xb6' because input provided python was = ' ö ' \x61\x20\x3d\x20\x27\xc3\xb6\x27 you told a contain byte sequence "\xc3\xb6" putting 2 bytes between quotes in console input, , does.

java - Eclipse complaining about Javadoc even after Disabling javadoc in compiler options, and inconsistent -

i've got open source code using {@code annotation eclipse complaining about. since don't care turned off javadoc in compiler options, it's still complaining , not compile compile. error is: "javadoc: missing closing brace inline tag" actually closing brace present. in cases it's few lines down, in others it's on same line! even stranger: same code in smaller project in different workspace works ok. i've compared 2 projects' settings couple times , appear same. in many cases options set not allow project specific settings. i did other things doing project clean, , trying java 1.5 vs. 1.7 compiler options, etc. other details: java 7 on mac eclipse kepler code guice 2.0 (i know that's old, , should use jar, long story) one example key.java line 107, see below example guice code (though wouldn't care since it's comments) /** ... * <p>{@code new key<foo>() {}}. @code tag has few cav

maven - org.apache.hadoop.conf.Configuration does not exist in hadoop-core.jar -

i writing hbase client in java. first line, of coz, looks this: import org.apache.hadoop.conf.configuration; i using cloudera cdh4.3.1, package versions should be: hadoop-2.0.0+1367 hbase-0.94.6+106 == updated == my pom.xml looks this: <dependency> <groupid>org.apache.hadoop</groupid> <artifactid>hadoop-core</artifactid> <version>2.0.0-mr1-cdh4.3.1</version> </dependency> <dependency> <groupid>org.apache.hbase</groupid> <artifactid>hbase</artifactid> <version>0.94.6-cdh4.3.1</version> </dependency> but somehow, in hadoop-core.jar, not seeing existence of org.apache.hadoop.conf.configuration. result of it, import not resolved java obviously. add hadoop-common pom.xml <dependency> <groupid>org.apache.h

c++ - Is a 2d array set up in memory contiguously similar to a 1d array simulating a 2d one? -

consider 2 type of array declarations: t x [rows * cols]; // type 1 t y [rows][cols]; // type 2 i use first type ( type 1) know index using x[row * cols + col] however if want copy 2d array 1d array simulating 2d array ie: copy type2 -> type1. if these guaranteed laid out same way in memory can memcpy of 1 other? have loop such if memory same layout in both thinking can memcpy. consider following public constructor below. public: // construct matrix 2d array template <unsigned int n, unsigned int m> matrix ( t (&twodarray)[n][m] ) : rows_(n), cols_(m), matrixdata_(new t[rows_*cols_]) { // there refactor here? maybe memcpy? ( unsigned int = 0; < rows_ ; ++i ) { ( unsigned int j = 0; j < cols_ ; ++j ) { matrixdata_[ * cols_ + j ] = twodarray[i][j]; } } } private: unsigned int rows_; unsigned int cols_; t* matrixdata_; a 2d array (the kind declared) guaranteed contiguous in memory.

How to save a files contents in Javascript/jQuery -

basically, want upload csv file via javascript or jquery. i want try , without php involved. i need use html upload form, , save it's contents multidimensional array or string. i not need save uploaded file server, need save it's contents string stated. i have looked far , wide online, yet involves php. is possible javascript or jquery? thanks in advance this uses library wrote , released under gplv3 license: html5csv the example below uploads csv file browser, available array of arrays. the library supports various block operations, such make table, edit, plot, fit, call function, save in browser session storage or local storage. jsfiddle html choose csv file load application: <input id='foo' type='file'> <hr /> js (requires jquery , html5csv.js) csv.begin('#foo'). table('output', {header:1, caption:'uploaded csv data'}). go(); here, go() can take function callback (e

jquery - Event bubbling up to match the original selector -

i have recurring problem event bubbling jquery i'm looking super simple solution to. let's have link: <a href="http://www.google.com" class="link"><span>link text</span></a> and bind click event jquery with: $('.menu a.item').bind('click', function(e){ e.stoppropagation(); e.preventdefault(); var obj = $(e.target); // obj }); the problem consistently face above , similar bindings if inner html of element has other tags events become target. that's fine dandy of course, i'm wondering if there quick , easy way parent() until parent() obj equal selector "a.item" can grab href value , it. in above case, simple $(e.target).parent().attr('href') work in case there 3 or 4 levels deep of child elements. does have ideas? just use this instead of e.target http://jsfiddle.net/fax4j/

javascript - How do I read and write a file on Phonegap? -

i looking through filewriter , filereader apis cordova , understand asynchronous. i've managed filewriter , filereader work separately following full examples here. but wondering if there way read file after writing it. code below shows want in gotfilewriter function ondeviceready() { window.requestfilesystem(localfilesystem.persistent, 0, gotfs, fail); } function gotfs(filesystem) { filesystem.root.getfile("readme.txt", {create: true, exclusive: false}, gotfileentry, fail); } function gotfileentry(fileentry) { fileentry.createwriter(gotfilewriter, fail); } function gotfilewriter(writer) { writer.onwriteend = function(evt) { // read file after writing }; writer.write("some sample text"); } function fail(error) { console.log(error.code); } filereader in full example documentation requires file object read (that gotfilewriter method lacks reference to). however, of asynchronous process reading files similar wri

android - Imageloader not loading image on real device -

i using imageloader class load image url , displaying in list view. imageloader loading image on emulator, when run app on real device it's not loading image.(just showing default image). please tell me have imageloader class working on real device. imageloader class: public class imageloader { memorycache memorycache = new memorycache(); filecache filecache; private map<imageview, string> imageviews = collections .synchronizedmap(new weakhashmap<imageview, string>()); executorservice executorservice; // handler display images in ui thread handler handler = new handler(); public imageloader(context context) { filecache = new filecache(context); executorservice = executors.newfixedthreadpool(5); } final int stub_id = r.drawable.products; public void displayimage(string url, imageview imageview) { imageviews.put(imageview, url); bitmap bitmap = memorycache.get(url);