Posts

Showing posts from March, 2015

c++ - std::cout not printing the value with out endl (newline specifier) -

below c++ program multiply 2 strings (integers in strings) , produce integer result in string. believe due cout flush problem. can explain how print value without endl or text string before printing answer. #include <iostream> using namespace std; string multiply (string s1, string s2) { char str[10]; string ans=""; int m=s1.length(); int n=s2.length(); if (!s1.compare("0") || !s2.compare("0")) return "0"; int *res = new int[m + n]; (int = m - 1; >= 0; i--) { (int j = n - 1; j >= 0; j--) { res[m + n - - j - 2] += (s1[i] - '0') * (s2[j] - '0'); res[m + n - - j - 1] += res[m + n - - j - 2] / 10; res[m + n - - j - 2] %= 10; } } (int = m + n - 1; >= 0; i--) { if (res[i] != 0) { (int j = i; j >= 0; j--) {

sharepoint jquery autocomplete clear textbox if no value -

i created textbox works on autocomplete function based on data list. need clear textbox if user has not selected item or has entered wrong text. below code $.ajax({ url: "http://address/_vti_bin/lists.asmx", type: "post", datatype: "xml", data: soapenv, contenttype: "text/xml; charset=\"utf-8\"", success: function (xmlresponse) { var domelementarray = $("z\\:row", xmlresponse); var datamap = domelementarray.map(function () { return { value: $(this).attr('ows_airportcode'), id: $(this).attr('ows_airportcode') }; }); var data = datamap.get(); //find sharepoint portal search box (this poor selector, not named sharepoint, inamingcontainer getrs in way) $("input[title='airportcode required field']").

java - OrientDB Complete Embedded Cluster Test -

i trying create simple test that: activates full server embedded instance ( embedded server , distributed configuration ) creates initial test database in document mode during first run ( create database ) opens test database ( open database ) insert sample record fetch sample record add node , repeat i can understand steps individually having difficulty piecing simple test case. example, api documentation assumes remote connection. not sure whether applicable method here, , if so, url should specify. once have completed steps 1, 2 , 3 correctly, should able refer api documentation steps 4 , 5. as novice user, find difficult interpret documentation in context. or clarification appreciated. i trying run test junit test. here have far: public class testorientdb { private static final logger log = logger.getlogger(testorientdb.class); @test public void testfullembeddedserver() throws exception { log.debug("connectiong database server..."); string

python - Image flickering in PyGame? -

i'm trying send "waves" of enemies code: wavechooser = random.randint(1, 4) print wavechooser if wavechooser == 1: wave1() but when run this, enemies send using wave1() keep flickering. wave1() code runs fine wihtout wavechooser, wavechooser comes problem. i'm guessing because wavechooser in while statement, values of wavechooser keep changing. so question is, how keep enemy opaque? prefer not change if statement because want send multiple waves @ once. wave1() code: def wave1(): global timer global timer1 global angle speed = random.uniform(0.1, 0.9) index = 0 # removing enemies enemy1 in enemies: if enemy1[0] < 330: enemy.pop(index) enemy1[0] -= speed index += 1 enemy1 in enemies: screen.blit(enemy, enemy1) as said, part seems working fine individually. edit: also, after send wave, can't seem able send one. need post more code? edit: of outputted values of wavechooser 3

algorithm - master theorem and recurrence -

Image
i given recurrence t(n) = 3t(n/2) + n^2 lg(n) is possible use master theorem find t(n) = theta(f(n))? there polylogarithmic function f(n) understand there limited 4th case. 4th case apply here? master's theorem not have constrains regards f(n) function: so = 3, b = 2, c = log2(3), , fall in third case , solution o(n^2 log n)

ruby on rails - Comments to a specific product appear for all products -

hello developing demo ecommerce app, have created products, users , comments. each product page should show comments specific product. can comment product , can see comments product a, then, if check page of product b, see comments of product a. basically, comments mixed in long list instead of being sorted product... here github : https://github.com/adsidera/freshobst following partial products/_comment.html.erb comments <div class="product-reviews"> <% @comments.each |comment| %> <div class="row" style="padding-left:4%;"> <hr> <p><small><%= comment.user.first_name %><em><%= " #{time_ago_in_words(comment.created_at)} ago" %></em></small></p> <div class="rated" data-score="<%= comment.rating %>"></div> <p><%= comment.body %></p> <% if signed_in? &a

best way to access JCR data AEM 6.0/ cq5 -

i know, in following 3 ways, 1 should used access jcr data. resolverfactory.getserviceresourceresolver(map authinfo); resolverfactory.getresourceresolver(map authinfo); session.getservice('servicename', null); could please share knowledge on these specific methods , how provide authinfo , in scenarios each of these methods used. it seems, aem 6.0 onwards getadministrativeresourceresolver method deprecated because of security reasons ?? thank you, sri from aem 6.1 cannot use "admin" access nodes. have detailed solution here resourceresolverfactory getserviceresourceresolver throws exception in aem 6.1 and here's have done read , write data jcr. public class interacthelper { @reference private resourceresolverfactory resolverfactory; private resourceresolver resourceresolver; @activate private void activate(componentcontext context) { ... map<string, object> param = new hashmap<string, object>(); // aem_subserv

swift - Integration of adMob: Unexpectedly found nil while unwrapping an optional value -

i have switched on iad admob , having hard time integrating banner ads. when run code, fatal error: unexpectedly found nil while unwrapping optional value here code: import googlemobileads class gameviewcontroller: uiviewcontroller, gadbannerviewdelegate { override func viewdidload() { super.viewdidload() let scene = gamescene(size: view.bounds.size) let skview = view as! skview skview.showsfps = false skview.showsnodecount = false skview.ignoressiblingorder = true scene.scalemode = .resizefill skview.presentscene(scene) print("google mobile ads sdk version: " + gadrequest.sdkversion()) var banner: gadbannerview! banner.delegate = self banner.adunitid = " ca-app-pub-xxxxxxxxxxx/xxxxxxxxxx" //crashing on line banner.loadrequest(gadrequest()) } } i feel i've followed admob website, im having hard time figuring out error coming from. is/has else had problem? you haven't in

ios - How to stop UIActivityIndicator after UISearchBar has finished in Swift -

so set up: i'm have app set parse, , i'm using pfquerytableviewcontroller . i've added uisearchbar screen. have search set , working fine. question: make bit more obvious user search being performed, want add uiactivityindicator can see loading. beginignoringinteractionevents() cannot use app until search complete. i'm having issues how make uiactivityindicator stop animating, , endignoringinteractionevents() - can't work out place code: spinningactivityindicator.stopanimating() uiapplication.sharedapplication().endignoringinteractionevents() i have placed code uiactivityindicator inside method func searchbarsearchbuttonclicked(searchbar: uisearchbar) once click search on keyboard, spinner start. but can place code stop animating , enable app again? the code added uisearchbar follows: func searchbartextdidbeginediting(searchbar: uisearchbar) { searchbar.showscancelbutton = true self.loadobjects() } func searchbartextdidendedit

how do I add a loader to this jquery ajax function -

i have following html <a href="/loadme.html" class="next">load content</a> <a href"/loadmeto.html" class="next">load other content</a> <div id="ajaxcontent"></div> <div id="ajaxloader">*obligatory animated gif*</div> and following jquery first loads content on initial page load, , subsequently overwrites other content when .next buttons clicked: // load default initial content $(document).ready(function() { $('#ajaxcontent').load('/keyplate/1'); }); // dynamically content via ajax $(document).on("click", ".next", function(){ var link = $(this).attr('href'); $('#ajaxcontent').fadeout('fast', function() { $.get( link +' #ajaxcontent', function(data) { $("#ajaxcontent").html(data).fadein('fast'); }, &quo

python - Pyhook UTF-8 issue -

i'm making python app triggers action when print screen key pressed. i'm using pyhook library. however, every time press character written language of country (ãíé , others) doubling characters . example : ~~a ''e ''i , causing problems in normal user written use. there way fix ? try add line: # -* - coding: utf-8 -* -

swift - List expects 3 elements but I don't know from where third comes -

so trying follow tutorial oauth 2.0 here . under section "oauthswift embedded web view". whole function: // 1 create oauth2swift object let oauthswift = oauth2swift( consumerkey: "your_google_drive_client_id", // 2 enter google app settings consumersecret: "your_google_drive_client_secret", authorizeurl: "https://accounts.google.com/o/oauth2/auth", accesstokenurl: "https://accounts.google.com/o/oauth2/token", responsetype: "code" ) // 3 trigger oauth2 dance oauthswift.authorizewithcallbackurl( nsurl(string: "com.raywenderlich.incognito:/oauth2callback")!, scope: "https://www.googleapis.com/auth/drive", // 4 scope state: "", success: { credential, response in var parameters = [string: anyobject]() // 5 embedded http layer , upload oauthswift.client.postimage( "https://www.googleapis.com/upload/drive/v2/files", paramete

c# - Is it reliable to use Last Modified timestamp of directory while doing a backup? -

i'm designing simple incremental backup tool. possible, after modify contents of directory, "last modified" attribute of directory stay intact? reason might ntfs glitch or bug, don't know. i found out there option ntfsdisablelastaccessupdate . possible turn off modification timestamp update? i want know how reliable attribute is, can decide if it's idea use make backups of filesystem. i'm using filesysteminfo.lastwritetime extract information in c#. i not think, last modified timestamp reliable. the timestamp decided file system using. e.g. fat32 uses local timestamp when dealing modified/created time. while ntfs uses utc timezone. also, fat32 has around 2 second resolution last write times . means cannot accurately record last modified date seconds. also, when copying files fat32 ntfs , see whole bunch of other timestamp problems . there rules how timestamp decided filesystems moreover , change timestamp of files , fold

mongodb - Combine full text with other index -

i have full text index , index on created date. my query on date alone returns nice, small 44 records (within second): > db.onemilliondocumentsindexed.count({created: {$lte: isodate("2016-02-06t15:34:59.019z")} }) 44 however, if combine text search query incredibly slow: > db.onemilliondocumentsindexed.count({ created: {$lte: isodate("2016-02-06t15:34:59.019z")}, $text: { $search: "raven" } }) it appears use both indexes: { "queryplanner" : { "plannerversion" : 1, "namespace" : "test.onemilliondocumentsindexed", "indexfilterset" : false, "parsedquery" : { "$and" : [ { "created" : { "$lte" : isodate("2016-02-06t15:34:59.019z") } },

node.js - Ionic installation after Ionic2 installation -

i tried install ionic2 no success, decided go ionic during process went bad , can't re-installl ionic , cordova. after sudo npm install -g cordova ionic , tried run ionic , got: xx@xxx:~/dev$ ionic info module.js:328 throw err; ^ error: cannot find module 'xmlbuilder' @ function.module._resolvefilename (module.js:326:15) @ function.module._load (module.js:277:25) @ module.require (module.js:354:17) @ require (internal/module.js:12:17) @ object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:12:13) @ object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:436:4) @ module._compile (module.js:410:26) @ object.module._extensions..js (module.js:417:10) @ module.load (module.js:344:32) @ function.module._load (module.js:301:12) my versions are: xx@xxx:~/dev$ npm -v 2.14.12 gal@xxx:~/dev$ nodejs -v v0.10.25 xx@xxx:~/dev$ node -v v4.2.6

php - Wordpress Theme Modifications - Style.css Note Updating -

i'm working on website. using wordpress along theme. i'm trying make modifications theme. i'm doing via child theme recommended. i'm running issue i'm trying make changes in child's style.css . however, many of these changes not seem going through. as example (refer website here: coffeedev.com), i'm trying make main container's corners rounded. i'm doing 'border-radius' function. when in child theme's style.css, changes not take place. i'm trying understand why changes aren't taking place. from research, believe either due webhosting (through godaddy) having kind of server caching, changes aren't updating when reload page, or due underlying overriding taking place. however, i'm not familiar enough css determine overriding take place. any appreciated! issues when server running ats, varnish or similar cache utility author has no control over. cache files stick around while , users have no control on c

node.js - node js module not found for directory of tape tests -

i have following structure: src/examples/test_file.js src/test/example.test.js package.json: "scripts": { "test": "node ./test/*.test.js" }, i have tape installed via npm install tape --save i run npm test , get: > node ./test/*.test.js module.js:328 throw err; ^ error: cannot find module 'c:\src\test\*.test.js' @ function.module._resolvefilename (module.js:326:15) @ function.module._load (module.js:277:25) @ function.module.runmain (module.js:430:10) @ startup (node.js:141:18) @ node.js:1003:3 npm err! test failed. see above more details. per this: https://ci.testling.com/guide/tape tests on whole dir should work global install of node package. how can above work without globally installing tape? i using node 5.4 , windows 10 edit: this works fine me on mac, , works fine on linux build server. assuming windows related how can set other file run other tests? one opt

errors in java when trying to call objects, setters getters and constructors -

when try call object different class , make setters , getters , make constructors in java eclispe keeps coming errors saying "duplicate local variable myclasstwoobject syntax error, insert "}" complete methodbody at myclass.main(myclass.java:180)" enter code h /*calling object myclasstwo example *calling object myclasstwo example */ myclasstwo myclasstwoobject = **new myclasstwo();** myclasstwoobject.chicken(); system.out.println(); system.out.println(); /*example of return statement *example of return statement */ int x = returnseventyseven(); system.out.print(x); system.out.println(); int result = square(3); system.out.println(); system.out.println(result); system.out.println(); /*getters & setters example *getters & setters exaple */ myclasstwo obj1 = **new myclasstwo();** obj1.setx(25); system.out.print(obj1.getx()); myclasstwo **myclasstwoobject** = new myclasstwo("dog"); myclass

c++ - Cropping an image on Qt -

i'm building simple image editor on qt.i have opened image on qgraphicsview , want able crop it.after lot of search came code doesn't work. void mainwindow::on_openbutton_pressed() { qstring imagepath=qfiledialog::getopenfilename(this,tr("open file"),"",tr("jpeg (*.jpg *.jpeg);;png (*.png)")); imageobject=new qimage(); imageobject->load(imagepath); image=qpixmap::fromimage(*imageobject); scene = new qgraphicsscene(this); scene->addpixmap(image); scene->setscenerect(image.rect()); ui->graphicsview->setscene(scene); ui->graphicsview->setdragmode(qgraphicsview::rubberbanddrag); showevent(); } void mainwindow::mousepressevent(qmouseevent *event){ start=event->pos(); } void mainwindow::mousereleaseevent(qmouseevent *event) { end=event->pos(); } void mainwindow::on_cropbutton_clicked() { start=ui->graphicsview->mapfromscene(start); end=ui->graphicsview-&g

multithreading - Are Thread Safety and Data Race condition addressing the same issue? -

i confused. understand, piece of code thread-safe if functions correctly during simultaneous execution multiple threads. , data race occurs when 2 instructions different threads access same memory location, @ least 1 of these accesses write , there no synchronization mandating particular order among these accesses. its clear both relate concurrency. addressing same thing? if program(or part) has data race , there high probability program not thread safe . thread-safety declares ultimate property program, uses multithreading. checking property is difficult task , cannot fully performed automatically (because term correctness in multithreaded case badly formalized). data race declares event, (relatively) easy check automatically , , having event has high correlation thread-unsafety . summarized: no data race - program can be thread safe . data race - program unlikely thread safe . some languages prohibit write programs data races. such langu

Python File errors -

Image
file = input("please enter name txt. file: ") filename = (file + ".txt") write = "w" append = "a" file = [] name = " " while name != "done" : name = input("please enter guest name (enter done if there no more names) : ").upper() filename.append(name) filename.remove("done") print("the guests list in alphabetical order, , save in " + filename + " :") file.sort() u in file : print(u) file = open(filename, mode = write) file.write(name) file.close() print("file written successfully.") i practicing write file in python, bad happened. here still errors this: filename.remove("done") still showing 'str' error. filename=filename+name use above code

Regex Find/Replace in Notepad++ including new lines -

Image
need replace/remove multiple occurrences in notepad++ using regex. here example: .... something<item>text removed or replaced</item> text<item>another text removed or replaced</item> <item>more text removed or replaced</item> ... i need replace/remove in between "<item>" , "</item>" , matches include new line. so end this: .... something<item></item> text<item></item> <item></item> ... one way find/replace : find what: (<item>).*?(<\/item>)\r? replace with: $1$2 check the: . matches new line more information: how use regular expressions in notepad++ (tutorial)

"ant -p" does not show all targets -

i know build.xml contains @ least ten targets, 2 show when run ant -p : $ ant -p build.xml buildfile: /home/nico/myproject/build.xml main targets: clean clean default target: deploy how display targets? ant -p shows targets have description. to show targets, run ant -p -v . generate quite lot of lines, full list of targets findable @ end of output: apache ant(tm) version 1.9.6 compiled on july 8 2015 trying default build file: build.xml buildfile: /home/nico/myproject/build.xml detected java version: 1.7 in: /usr/lib/jvm/java-7-openjdk-amd64/jre detected os: linux parsing buildfile /home/nico/myproject/build.xml uri = file:/home/nico/myproject/build.xml project base dir set to: /home/nico/myproject parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml uri = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml zip file importing file /home/nico/ide/build-common-portlet.xml /home/nico/myproject/build.xml overridin

android - Do I have to publish my app under the same Google account that I configured Google Play Services? -

under google account #1, have google+ , google maps enabled/configured android app. in app, using app id configured under account allows me use g+ sign in , google maps. will able publish app under separate google account , have google services still work? i've looked around couldn't find information stating whether or not can (or should) use same account configure google play services , publish app. i not think mandatory, , in past have done these things separate google accounts

robotframework - Json handling in ROBOT -

i have json file , in there field need edit , save file next usage. but field need edit shown below, the val need assing fr field generated randomly in run time i'll capturing in variable , pass json specific key "dp" save json. the saved json used rest post url. { "p": "10", "v": 100, "vt": [ { "dp": "field edited"(integer value) , ] } please me out , using robot framework, need update json field in run time. the simplest solution write python keyword can change value you. however, can solve robot keywords performing following steps: convert json string dictionary modify dictionary convert dictionary json string convert json string dictionary python has module ( json ) working json data. can use evaluate keyword convert

xaml - Change the foreground of a button when clicked -

so trying change color of button when clicked i've spent amount errors , couldn't find helpful. understand brand new visual studio 2015 community. there seems lot of ways either using brushes or solidcolorbrushes or conversion. please mention using , references needed here button: <button x:name="castbutton" click="castbutton_click" horizontalalignment="right" verticalalignment="bottom" margin="0,0,35,10" fontfamily="segoe mdl2 assets" fontsize="24" foreground="aliceblue" content="&#xe72d;"> </button> if want change foreground color when button pressed, have modify style of control. right click on button in designer window, edit template -> edit copy - should create copy of default template in resources, should this: <page.resources> <style x:key="mybuttonstyle"

java - How to store timestamp in mysql based on Timezone? -

i want store timestamp last_login in login table. creating time in dao layer , updating in table when user logs in. problem is, want update based on timezone. code is simpledateformat formatter = new simpledateformat("dd-mm-yyyy hh:mm:ss"); final timezone utc = timezone.gettimezone("ist"); formatter.settimezone(utc); calendar c = calendar.getinstance(); c.add(calendar.date, 0); // number of days add string date = (string) (formatter.format(c.gettime())); date converteddate = formatter.parse(date); date timestampobj = new timestamp(converteddate.gettime()); this returning me timestamp of server. if server in uk, timestamp of uk. know mysql timestamp stores time in utc. rather saving time in ist, saving time in uk. how shall proceed? from gather, need verify server time. check operating systems time set ist (utc offset: utc +5:30).

c# - Exception Handling in WCF's Completed Event -

i wondering how catch exception in wcf's completed event method , show user in messagebox . i call getproducttypeasync(); method fetches records database. want catch exception occurs here , send service_getproducttypecompleted event should show exception message user. public list<producttype> getproducttype() { list<producttype> producttype = new list<producttype>(); try { using (sqlconnection con = new sqlconnection(_connectionstring)) { sqlcommand cmd = new sqlcommand("usp_get_producttype", con); cmd.commandtype = commandtype.storedprocedure; con.open(); using (sqldatareader reader = cmd.executereader()) { while (reader.read()) { producttype ptype = new producttype(convert.toint32(reader["pkproducttypeid"]), reader["name"].tostring()); producttype.add(ptype);

Cassandra and Apache Ignite Integration for Write-through and Read-through? -

i want integrate apache ignite in-memory feature in apache cassandra. how can ? ay plugin avaliable write-through , read-throught ? can possible architecture efficient insertion , retrieval ? to should implement cachestore interface , provide in cacheconfiguration . see [1] more details , examples. also note there cassandra store implementation in development [2], integration provided out of box. can watch ticket track progress. [1] https://apacheignite.readme.io/docs/persistent-store [2] https://issues.apache.org/jira/browse/ignite-1371

ios - Printing string arrays to UILabels -

is there way print out array of strings uilabel without special characters, i.e. ["number1","number2","number3"] i want in uilabel output: number1 number2 number3 here code: let addinputs = quantityfield.text! + "x " + descriptionfield.text! var listarray: [string] = [] listarray.append("\(addinputs)") addinputs in listarray { //itemlistlabel.text = "\n\(addinputs)" print("\(addinputs)") itemlistlabel.text = "\(listarray)" } you can join items \n add hard return: itemlistlabel.text = listarray.joinwithseparator("\n")

java - Libgdx when using skin in a Label it does not show when the application is being run -

i've trying give background labels in libgdx because without custom skin, left blank slate white text. using skin editor found here , able make style of label liking want use in project. however, use of these files build skin, nothing seems happen. with these files, i've tried using: skin1 = new skin(gdx.files.internal("skins/uiskin.json"), new textureatlas(gdx.files.internal("skins/uiskin.atlas"))); and using in table: table table = new table(skin); and in labels: label label = new label("test", skin); but no avail. does have idea why still shows plain white text? thank much. this uiskin.json file { com.badlogic.gdx.graphics.color: { green: { g: 1, a: 1 }, light_grey: { r: 0.8, g: 0.8, b: 0.8, a: 1 }, white: { r: 1, g: 1, b: 1, a: 1 }, red: { r: 1, a: 1 }, yellow: { r: 1, g: 1, a: 1 }, grey: { r: 0.7, g: 0.7, b: 0.7, a: 1 }, black: { a: 1 } }, com.badlogic.gdx.graphics.g2d.bitmapfon

html - How to allow the path elements in an svg element to overflow the container -

i writing animation logo ( here link codepen), can see code there well, post here well. so targeted every path element , changed it's properties , works fine, except fact since use "transform" move elements because leave container , hidden. this css svg element svg { width:400px; height:400px; margin-top:100px; margin-left:calc(50% - 200px); transform-style:preserve-3d; overflow:visible; } i tried adding viewbox inline property svg tag didn't work either, can do? want every path visible no matter is, possible? thank in advance. the overflow: visible rule added css definition svg should have worked. the reason didn't because svg had <clippath> had effect of hiding overflow. when rid of also, things behave wanted. demo codepen to rid of clip, deleted <clippath></clippath> element, , clip-path="url(#clippath20)" reference <g> . both of these near start of document.