Posts

Showing posts from February, 2014

c# - Could some one check for me if my unit test for the FillUpWater is correct -

could tell me correct unit test fillupcontainer()? namespace coffeemaker { [testclass()] public class watercontainer { //private watercontainer waterc; watercontainer waterc = new watercontainer(0); int level = waterc.level; [testmethod()] public void fillupwatertest() { if (waterc.level == 0) { bool result; result = waterc.fillupwater(); } level.equals(5); } } } no, it's not. level.equals(5) not assertion, it's expression, result of throw away not assigning anything. a better test might this: [testclass()] public class watercontainer { [testmethod()] public void whenwatercontainerisempty_fillingitup_causescorrectwaterlevel() { // arrange watercontainer water = new watercontainer(...

email - Record/copies of PHP mail() previously sent from our website? -

should there record of php sent mail (via our hosts mail() function) anywhere? our web developer made oversight , enquiries sent via our host's (godaddy.com) mailer relay last 2 months rejected our local mail server. naturally, our server doesn't keep rejected emails. i have spoken godaddy.com , claim there no record, i'm not particularly confident answer. is there can do? enquiry form fixed (used mandrill), that's not issue. no, mails gone now. rejected mails mail server tried send go mail admin account of sending server bounce - however, account might not set or failing or rejecting mail, mail server rid of these undeliverable mails double-bounced deleting them queue. you might idea of tried mail if able hand onto mail server logfile, assuming in hands of hosting provider, chances low: 1. these logs give idea of mail addresses involved, no content. 2. log files deleted because they'd serve no regular purpose.

.htaccess - URL rewriting with PHP -

i have url looks like: url.com/picture.php?id=51 how go converting url to: picture.php/some-text-goes-here/51 i think wordpress same. how go making friendly urls in php? you can 2 ways: the .htaccess route mod_rewrite add file called .htaccess in root folder, , add this: rewriteengine on rewriterule ^/?some-text-goes-here/([0-9]+)$ /picture.php?id=$1 this tell apache enable mod_rewrite folder, , if gets asked url matching regular expression rewrites internally want, without end user seeing it. easy, inflexible, if need more power: the php route put following in .htaccess instead: fallbackresource index.php this tell run index.php files cannot find in site. in there can example: $path = ltrim($_server['request_uri'], '/'); // trim leading slash(es) $elements = explode('/', $path); // split path on slashes if(empty($elements[0])) { // no path elements means home showhomepage();...

Parse.com Query with swift 1.2 and string array -

i trying query parse.com , db receiving 100 objects per time. used swift example code on website, , app doesn't build code. looked around , found people using code similar this: var query = pfquery(classname:"posts") query.wherekey("post", equalto: "true") query.findobjectsinbackgroundwithblock({ (objects: [anyobject]?, error: nserror?) -> void in // self.mydataarray = objects as! [string] }) this not work, because trying convert pfobject string i need 1 one value each object swift string array [string]. how 1 text value, instead of pfobject , how swift string array? i don't speak swift well, problem code it's trying cast returned pfobject string, want extract string attribute, (if want it): for object in objects { var somestring = object.valueforkey("someattributename") string self.mydataarray.addobject(somestring) } but please make sure need this. i've noticed l...

java - QuickSort breaking -

i trying parallelize quick sort wrote serial version first partition , recursive sort on both partitions. works.. until sizes of > 100,000 in case if 1 of partitions big goes forever , never finishes. can't figure out why is. run in 13-15 ms @ 100k @ 120k either run @ around same time or not @ all. for partition picked pivot based on median of first, middle, , last elements of current partition , if equal goes last element. here's partition: private static int partition(int low, int high, int[] array){ //get median of first, last, , middle element in our section int lval, hval, mval, pindex, pval; lval = array[low]; hval = array[high]; mval = array[((high-low+1)/2) + low]; //system.out.println("low: " + low + "high: " + high); if (lval < hval && lval > mval || lval > hval && lval < mval){ pindex = low; //system.out.println("picking low index: " + low); } else i...

python 3.x - code printing wrong answer -

write function first_last6(nums) takes list of ints nums , returns true if 6 appears either first or last element in list. list of length 1 or more. my code: def first_last6(nums): if nums[0] or nums[-1] == "6": return true else: return false it not returning right answer test: print(first_last6([3, 2, 1])) its suppose false , while prints true . the original test checks if nums[0] true or if nums[-1] 6, check if either 6, should use: if nums[0] == 6 or nums[-1] == 6:

linux - input directory as command line arguement in c -

i building program copies directories each other, can work hard coded. i want directory input user via command line argument. i have used char srcpath[] = argv[1]; however when hard code char srcpath[] = "home/user/desktop/cat"; works fine. but doesn't work, can explain why / suggest way this? , there special way directories have input when used in cli? argv[] array of char pointers, therefore when use argv[1] obtaining second item in array char pointer. james suggested if want store value of argv[1] memory address have use identical type in case char * . if need save directory path sort of processing or manipulation, need store command line argument inside char array. char srcpath[100]; int i; (i = 0; argv[1][i] != '\0'; i++) { srcpath[i] = argv[1][i]; } array names pointers using subscript [] dereferences it. same can said char arrays stored inside of argv[]

android - Handling application specific actions after device is waking up from sleep -

i storing application specific data in db. want perform different actions when application first time opened after device wake sleep application opened 2nd/more times after waking sleep how can this? e.g camera opened after device wake - first time - application ask password camera opened 2nd time wont ask password whatsapp opened after device wake - first time - application ask password whatsapp opened 2nd time wont ask password implement if-else on service broadcastreceiver run everytime device turned on, example : <receiver android:name="com.example.mybroadcastreceiver"> <intent-filter> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> and dont forget add permission : <uses-permission android:name="android.permission.receive_boot_completed" />

minitest - I'm getting an undefined method error when running tests on rails 4 with guard -

i happily working along in hartl's tut (exactly here https://www.railstutorial.org/book/filling_in_the_layout#code-contact_page_test ) when started getting error in guard , have not been able find methods or method calls regarding '[]', appreciated. https://github.com/mgmacri/sample-app 02:23:12 - info - running: /home/ubuntu/workspace/sample_app/db/schema.rb doesn't exist yet. run `rake db:migrate` create it, try again. if not intend use database, should instead alter /home/ubuntu/workspace/sample_app/config/application.rb limit frameworks loaded. started error["test_should_get_contact", staticpagescontrollertest, 5.435833117] test_should_get_contact#staticpagescontrollertest (5.44s) actionview::template::error: actionview::template::error: undefined method `[]' nil:nilclass app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___423443063036763089_70222525057280' test/controllers/...

Basic prime number generator in Python -

just wanted feedback on prime number generator. e.g. ok, use resources etc. uses no libraries, it's simple, , reflection of current state of programming skills, don't hold want learn. def prime_gen(n): primes = [2] = 2 while < n: counter = 0 in primes: if % == 0: counter += 1 if counter == 0: primes.append(a) else: counter = 0 = + 1 print primes there few optimizations thar common: example: def prime(x): if x in [0, 1]: return false if x == 2: return true n in xrange(3, int(x ** 0.5 + 1)): if x % n == 0: return false return true cover base cases only iterate square root of n the above example doesn't generate prime numbers tests them. adapt same optimizations code :) one of more efficient algorithms i've found written in python found in following question ans answer ( using...

html - How to tell Chrome or Safari to display a page with certain encoding? -

i accessing page: http://protege.stanford.edu/publications/ontology_development/ontology101-noy-mcguinness.html when saw browsers (safari , chrome) don't display characters (prot�g� when it's supposed protégé). i think it's because content not sent utf-8 encoding, chrome , safari default utf-8 when encoding not mentioned in html page (in <meta> tag). i tried saving page through safari (it doesn't work through chrome) in sublime text 2 , tell "save encoding" utf-8, , can see it's displaying correctly, don't know original encoding used. obviously don't have control on website, , cannot change content send. think need tell browser use specific encoding used when server encoded page. so have 2 questions: what encoding used on page display page properly? how can tell chrome or safari use encoding? new answer i apologize hasty answer. in chrome, can override encoding going menu > more tools > encoding. tested p...

c# - How string allocates the memory in heap? -

i confused in memory allocation while creating object of string class. have created sample application demonstrates how memory being allocated when string object declared. have tried increase length of string see difference total consumed memory in heap. my testing code here static void main(string[] args) { long l1 = gc.gettotalmemory(false); long l2 = 0; console.writeline(l1.tostring()); myfunc(); l2 = gc.gettotalmemory(false); console.writeline(l2.tostring()); console.writeline(string.format("difference : {0}", (l2-l1))); console.readkey(); } private static void myfunc() { string str = new string('a', 1); } the output comes when execute code: 775596 //memory @ startup 816556 //after executing function difference : 40960 the above output same string length 0 2727. example create object of string length of 2727 out comes same above. string str = new string('a', 2727); but, when increase 1 more in value...

java - Red5 - Getting an error when I try to connect to server -

i following error when try establish connection between flash plugin , red5 server installation. please me. [error] [rtmpconnectionexecutor#dtqatxjixlu78-1] org.red5.server.net.rtmp.basertmphandler - exception java.lang.nosuchmethoderror: org.red5.server.scope.scope$concurrentscopeset.keyset()ljava/util/concurrent/concurrenthashmap$keysetview; @ org.red5.server.scope.scope$concurrentscopeset.hasname(scope.java:1411) ~[red5-server-common-1.0.5-release.jar:na] @ org.red5.server.scope.scope.haschildscope(scope.java:819) ~[red5-server-common-1.0.5-release.jar:na] @ org.red5.server.scope.scoperesolver.resolvescope(scoperesolver.java:99) ~[red5-server.jar:na] @ org.red5.server.context.resolvescope(context.java:154) ~[red5-server.jar:na] @ org.red5.server.net.rtmp.rtmphandler.oncommand(rtmphandler.java:323) ~[red5-server-common-1.0.5-release.jar:1.0.5-release] @ org.red5.server.net.rtmp.basertmphandler.messagereceived(b...

jpa - Is Apache Olingo OData 2.0 Java Library support actions? -

i need call 1 database procedure in cud operation, rather direct insert/update/delete table. question if mapped entities jpa, possible me call separate function (action bounded operation, not function import unbounded operation) url via olingo. no. olingo v2 library supports odata v2 features, since actions of kind available odata v3 onwards not part of olingo v2.

python 3.x - Reducing the amount of return statements -

the following code returns bmi risk of person - either low , medium or high . works fine. however, wondering if there way solve without using many return statements. is there other way, either, pythonic or logically make shorter? def bmi_risk(bmi, age): ''' function returning bmi's risk on human ''' if bmi < 22 , age < 45: return "low" if bmi < 22 , age >= 45: return "medium" if bmi >= 22 , age < 45: return "medium" if bmi >= 22 , age >= 45: return "high" perhaps best, or @ least clearest, way through use of multiple if / elif / else blocks variable holding risk: def bmi_risk(bmi, age): ''' function returning bmi's risk on human ''' if bmi < 22 , age < 45: risk = "low" elif bmi < 22 , age >= 45: risk = "medium" elif bmi >= 22 , a...

printing - Send output of print to a new file in python? -

this question has answer here: what code mean: “print >> sys.stderr” 2 answers in section of program i'm making converted plain sequence of letters fasta format. need take fasta format , put in file form can send program come later in code. in line 3 created "fasta.txt". need put output of line 8, fastaform, in file. in last line tried didn't work , have no idea how. feel should pretty simple i'm new @ this. infname = sys.argv[2] handle = open(infname, "r") file = open("fasta.txt", "w") line in handle: linearr = line.split() seqid = linearr[0] seq = linearr[1] fastaform = (">%s\n%s\n" % (seqid,seq)) print fastaform >> "fasta.txt" try file.write(fastaform) file.close()

java - How to get total number of authenticated web hits? -

i using google analytic api in java google data 1 of website google account registered. able total number of hits between 2 specific dates, want retrieve total number of authenticated web hits. not getting proper way data using google analytic. the function have written getting number of hits is: private static gadata getwebhitsbymonth(analytics analytics, string profileid) throws ioexception { return analytics.data().ga().get(profileid, "2013-07-01", currentdate, "ga:hits") .setdimensions("ga:yearmonth") .execute(); } can give me idea this? since google analytics has no way of knowing whether or not user authenticated, have tell it. there 2 ways approach sending information google analytics: first (easier) custom dimension , , second (more involved, more useful) using user id feature. if go route of using custom dimension, you'll have set on tracker object know user logged in. assuming first custom dimen...

java - How to correctly write information into GlassFish log? -

i have built simple java servlet on eclipse kepler ide, glassfish 4.0 server. in order track output, used both system.out.println() , log.info() method java.util.logging , no information found in glassfish log file.

PHP ping to get response with the ip address -

i'm trying ping ip address test ip address whether available or not. having trouble on using fsockopen function. had research on using 'ping','exec' function none of them seem workable. here code test ip address: <?php $ipaddress = array("192.168.1.1","192.168.1.67"); $kiosk = array("kuantan (35)","utc kuantan (36)"); $checkcount = 0; foreach(array_combine($ipaddress,$kiosk) $items => $kiosk){ $fp = @fsockopen($items,80,$errno,$errstr,1); if(is_resource($fp)){ if($fp) { $status=0; fclose($fp); echo 'success<br/>'; } } else{ echo 'failed<br/>'; } } ?> both ip address can ping cmd prompt. 192.168.1.67 lead me 'failed', 192.168.1.1. or 127.0.0.1 showing me 'success'. there wrong? your code not pinging tries o...

.net - How to scroll on increasing picturebox size in windows form c#? -

Image
i have picturebox control in windows form movable rectangle drawing in it, picturebox size increase according position of rectangle, when picturebox size greater particular size scrollbar appear. public void picbox_mousedown(object sender, mouseeventargs e) { if (rect.contains(new point(e.x, e.y))) { mmove = true; } oldx = e.x; oldy = e.y; } public void picbox_mouseup(object sender , mouseeventargs e) { mmove = false; } public void picbox_mousemove(object sender,mouseeventargs e) { if (mmove) { picbox.cursor = cursors.cross; rect.x = rect.x + e.x - oldx; rect.y = rect.y + e.y - oldy; } oldx = e.x; oldy = e.y; picbox.invalidate(); } public void picbox_mousepaint(object sender, painteventargs e) { picbox.invalidate(); picbox.size = new size((rect.width + rect.x) + 10, (rect.height + rect.y) + 10); draw(e.graphics); } on...

cmd - How to read a text file in bottom up manner using batch -

i working on project requires creation of resources, while creating resources write in file rollback creation process if error occurs. there catch in here, resources has deleted in opposite manner in created, when write in roll file : delete r1 delete r2 .. .. delete rn i want delete resources in order -> delete rn delete rn-1 .... ... delete r1 is there way in windows batch ? there no native way read file in reverse order using batch. but, while not fastest method, can solved reading file in normal order, prefixing each line padded number, sorting list in reverse order, splitting line separate numbers , process list @echo off setlocal enableextensions disabledelayedexpansion set "file=data.txt" /f "tokens=1,* delims=¬" %%a in (' cmd /v:off /e /q /c"set "counter^=10000000" & /f usebackq^ delims^=^ eol^= %%c in ("%file%") (set /a "counter+^=1" & echo(¬%%c)" ...

php - routes in codeigniter/pyrocms -

i saw route downloaded sample module @ pyrocms $route['sample(/:num)?'] = 'sample/index$1'; i tried removed '$1' above , site runs smooth. wondering what's for, , can remove it. $1 whatever matched (:num) group - is, really, valid numbers. whatever add passed parameter view method in pages controller. example $route['sample(/:num)?'] = 'sample/index/$1'; now in sample controller function index($id){ // $id matched group (:num) }

android - How to get full size image from custom front camera with full screen length -

i making android app using front camera of device , has take picture in portrait form want save picture in same result showing in preview when take photo , save bitmap bitmap seems awkward increases size in length. seems doing wrong squeezing camera picture while saving. i have searched many links , came know have set aspect ratio. did not it. want in coding because have complete app , working best on samsung grand , s4 not working on lg g3 , . here doing surfaceview class . sharing surface view class know there wrong here , rest of other classes easy . camerapreview.java public class camerapreview extends surfaceview implements surfaceholder.callback { private camera camera; public static surfaceholder holder; private activity activity; public camerapreview(context context, attributeset attrs, activity activity) { super(context, attrs); } public camerapreview(context context, attributeset attrs) { super(context, attrs); } public camerapreview(context context...

MongoDB select distinct and count -

i have product collection looks that: products = [ { "ref": "1", "facets": [ { "type":"category", "val":"kitchen" }, { "type":"category", "val":"bedroom" }, { "type":"material", "val":"wood" } ] }, { "ref": "2", "facets": [ { "type":"category", "val":"kitchen" }, { "type":"category", "val":"livingroom" }, { "type":"material", "val":"plastic" } ] } ] i select , count distinct categories , numb...

pagination - wp-pagenavi not working on custom query wordpress -

i face weird issue on wp-pagenavi plugin. using woocommerce plugin works perfectly. make page template , want show products product type bundle, products show wp-pagenavi not working. try on blog page working perfect there not in page template. here code: page template name <?php /* template name: bundle products */ get_header(); ?> my custome query <?php $paged = get_query_var('page') ? get_query_var('page') : 1; $gb_bundle_args = array( 'post_type' => 'product', 'order' => 'desc', 'paged' => $paged, 'tax_query' => array( array( 'taxonomy' => 'product_type', 'field' => 'name', 'terms' => 'bundle' )...

c++ - Reverse char string with pointers -

i need reverse char string pointers. how can this? code: // cannot modified !!! char s[10] = "abcde"; char *ps; // code ps = new char; int count = 5; (int = 0; < 10; i++) { if (s[i] != '\0') // not null { ps[count - 1] = s[i]; count--; } } cout << "reversed = " << ps; sometimes if works fine, see 5 chars, reversed. see chars (looks temp symbols). miss something? thank you! your char array "s" contains 10 chars, initialize first 6 chars of array "abcde" , \0 terminator. when loop on complete array, access not initialized chars. i see, try write memory, didn't allocate. allocate memory 1 char "ps" pointer, try access it's memory array of chars in for-loop. instead of using hardcoded: int count = 5; you use string function strlen() determine length of c-string. edited (untested code): char s[10] = "abcde"; char ps[10]; (int = 0; <...

javascript - How to filter out various titles with same keywords -

i have strings similar contain same keywords. if more 1 string has 3 or more of same keywords, want 1 string returned. example: ex machina example of female artificial intelligence. ex machina, why artificial intelligence represented female? artificial intelligence represented females in ex machina? i filter strings 3 keywords keep 1 string. not sure if can use regex alone or need javascript. help? how looping on sentences , removing punctuation, , keeping words in map. aggregate count , loop on hash find words have occurred more 3 function filter() { var sentences = [ "ex machina example of female artificial intelligence.", "ex machina, why artificial intelligence represented female?", "will artificial intelligence represented females in ex machina?" ]; var word_map = {}; (var = 0; < sentences.length; i++) { var cur_sentence = sentences[i]; cur_sentence = remove_punctu...

jquery - Click events running twice after re-opening the bootstrap modal -

currently working on codeigniter apps i loading view in bootstrap modal using ajax, loaded view has jquery events further have ajax calls. problem getting when click on button(which execute ajax) triggers once after closing modal , reopening clicked event running twice. $(document).on('click','.open_form',function(e){ e.preventdefault(); var task = $(this).attr('id'); $.ajax({ type: "post", url: "<?php echo site_url();?>client/getmodalview", data: {view:'invoice','<?php echo $this->security->get_csrf_token_name(); ? >':'<?php echo $this->security->get_csrf_hash(); ?>','task':task}, cache: false, context: document.body, beforesend:function(){ if(task == 'expense') { $('.modal-title').html('add expense'); }else if(task == 'uploadexpense'){ $('.modal-title').html('u...

c - Why is casting from int to void * allowed? -

why casting void* int , vice versa allowed in c? used other pthread ? it allowed, behavior implementation-defined. sometimes, under situation (on particular platform/ architecture), provision may useful quick-and-dirty hacks/tricks involving memory addresses using operators needs int operands. [ex: xor operation]. can useful memory optimization limited-memory embedded devices. to quote standard regarding functionality, the mapping functions converting pointer integer or integer pointer intended consistent addressing structure of execution environment. related reading: c11 , chapter 6.3.2.3, paragraph 5: an integer may converted pointer type. except specified, result implementation-defined, might not correctly aligned, might not point entity of referenced type, , might trap representation. and paragraph 6: any pointer type may converted integer type. except specified, result implementation-defined. if result cannot represented in integer ty...

javascript - Open the mobile device share dialog via web app -

problem: open mobile devices own share dialog when user clicks on button in our website, have local apps available. now: possible devices share dialog through web browser on phone? we use html5, css3 , javascript websites, no android sdk or iphone equivalent. apparently josé said not possible access devices share dialog directly through web browser. further investigations other possibilities done on our side.

javascript - jquery datepicker not working inside <h:form> -

i got datepicker code https://jqueryui.com/datepicker/ the source works such not work (no calendar pops up) inside tags inside jsp. source works fine (popup calendar comes) if input text placed outside h:form. using eclipse , jsf develop page here code: <%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com...

perforce - git-p4 clone command fails -

i'm trying run command: git-p4 clone -v //depot/path/project/v31a and fails error: importing //depot/path/project project reinitialized existing git repository in /home/xxx/downloads/p4tmp/v31a/.git/ reading pipe: ['git', 'config', '--bool', 'git-p4.useclientspec'] doing initial import of //depot/path/project/v31a/ revision #head refs/remotes/p4/master reading pipe: ['git', 'config', 'git-p4.user'] reading pipe: ['git', 'config', 'git-p4.password'] reading pipe: ['git', 'config', 'git-p4.port'] reading pipe: ['git', 'config', 'git-p4.host'] reading pipe: ['git', 'config', 'git-p4.client'] opening pipe: ['p4', '-g', 'files', '//depot/path/project/v31a/...#head'] opening pipe: ['p4', '-g', 'describe', '-s', '222342'] reading pipe: [...

php - Laravel 5 password reset not working -

i working on laravel 5 ecommerce web portal. i having issue when user updates password using ready made scripts. the issue can send link customer without issue , customer can change password also. when logged out , re-logging in, error invalid credentials . in routes.php, have this: route::controllers([ 'auth' => 'auth\authcontroller', 'password' => 'auth\passwordcontroller', ]); this login page: <form class="form-horizontal" role="form" method="post" action="{{ url('/login') }}"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <div class="form-group"> <label class="col-md-4 control-label">e-mail address</label> <div class="col-md-6"> <input type="email" class="form-control" name="email" value="...

ios - Getting Navigation Bar Color For View is Not Working -

i have getting navigation bar color , set view background color it's not same color in bar. don't know why it's doing so. solutions welcome , hope me in matter. code self.navigationcontroller.navigationbar.tintcolor = [uicolor bluecolor] uiview *view = [[uiview alloc] initwithframe:cgrectmake(0,0,20,20)]; view.backgroundcolor= self.navigationcontroller.navigationbar.tintcolor; in application design have same theme that's why it's not getting theme of navigation view background color there difference. use -[uinavigationbar bartintcolor] property instead of tintcolor ps. aware of translucency :)

c++ - invalid covariant return type error -

this question has answer here: in c++, possible forward declare class inheriting class? 4 answers i getting below error on overriding base class function in derived class. ./inc/rbtree.h:16:18: error: invalid covariant return type ‘virtual rbnode* rbtree::get_root()’ ./inc/tree.h:25:24: error: overriding ‘virtual node* tree::get_root()’ rbtree.h class rbnode; class rbtree: public tree { protected: public: rbtree(); rbnode *root; rbnode * get_root(); void insert_into_tree(); //void delete_from_tree(); }; and tree.h below class node; class tree { protected: node * root; list<int> treedata; public: tree(); /* gives error */ virtual node * get_root(); void set_root(node *root_node); void insert_into_tree(); void delete_from_tree(); ...

javascript - Stop bars from centering in chart -

i creating bar chart using d3. looked @ this code , changed little bit. however centering bars, , bars start immediate @ bar y axis. it looks issue comes these 2 pieces of code: var x = d3.scale.ordinal() .rangeroundbands([0, width], .0); and last line of one: svg.selectall(".bar") .data(graphobj) .enter().append("rect") .attr("class", "bar") .attr("x", function(d) { return x(d.step); }) where x(d.step) responsible distance, x set @ var x = ... somehow need change this, cant figure out. distance bit different since changed this: var x = d3.scale.ordinal() .rangeroundbands([0, width], .1); to this: var x = d3.scale.ordinal() .rangeroundbands([0, width], .0); but doesn't much. can out here? this code: $('#chartdiv').html(''); var margin = {top: 10, right: 10, bottom: 35, left: 50}, width = 600 - margin.left - margin.right, ...

node.js - Why isn't working my uploader from android to NodeJS server? -

i tried code, message http response is: 404 not found @suppresslint("sdcardpath") public class mainactivity extends activity { textview messagetext; button uploadbutton; int serverresponsecode = 0; progressdialog dialog = null; string uploadserveruri = null; /* filepath */ final string uploadfilepath = "/mnt/sdcard/"; final string uploadfilename = "test.jpg"; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); uploadbutton = (button)findviewbyid(r.id.uploadbutton); messagetext = (textview)findviewbyid(r.id.messagetext); messagetext.settext("uploading file path :- '/mnt/sdcard/"+uploadfilename+"'"); uploadserveruri = "http://192.168.0.12:9999"; uploadbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { dialog = progre...

android - How to add ActionBar to an activity which already extends ListActivity? -

i have activity extends listactivity . can add actionbar without extending actionbaractivity ? you can use new appcompatdelegate component provided support library. actionbar deprecated , should use toolbar , compliant material design. can use toolbar provided support library. add xml layout this: <android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minheight="56dp" android:background="?attr/colorprimary" /> be sure use noactionbar theme in styles.xml. use material design color tags. <style name="apptheme" parent="theme.appcompat.noactionbar"> </style> then, add appcompatdelegate activity, in oncreate(), this. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); appc...

mysql - Nodes unexpectedly closing in Mariadb Galera Cluster -

i've setup 3 node galera cluster application, there stored procedure in application creates table temporarily(not temporary table), table created dynamically , executed. crud operation done on table muptiple times , after usage completed dropped @ end of stored procedure. problem everytime run particular stored procedure 2 out of 3 node fails , shuts down automatically. here log node fails :- 05 seqnos (l: 38, g: 47, s: 46, d: 46, ts: 186965868554819) 150423 8:31:35 [error] wsrep: failed apply trx 47 4 times 150423 8:31:35 [error] wsrep: node consistency compromized, aborting... 150423 8:31:35 [note] wsrep: closing send monitor... 150423 8:31:35 [note] wsrep: closed send monitor. 150423 8:31:35 [note] wsrep: gcomm: terminating thread 150423 8:31:35 [note] wsrep: gcomm: joining thread 150423 8:31:35 [note] wsrep: gcomm: closing backend 150423 8:31:35 [note] wsrep: view(view_id(non_prim,4d2adf77-e972-11e4-be7e-6bcb3d5c882f,3) memb { 849bbb26-e981-11e4-9f9f-f37...

javascript - Click function still working for previous class which is already replaced by other -

i having problem jquery click event. when replace class of div click function still working previous class. here code working with: $(this).removeclass('edit_agent_val').addclass('edit_agent_val2'); the click function still working edit_agent_val instead of edit_agent_val2 . // should not work $('.edit_agent_val').on('click', function(e) { // code... }); // should work $('.edit_agent_val2').on('click', function(e) { // code... }); can me fix issue? the issue because events attached on load when element still has original class. act of changing class attribute not affect of events attached element. to achieve want need use delegated event handler, attached parent element: $(document).on('click', '.edit_agent_val', function(e) { // code... }); $(document).on('click', '.edit_agent_val2', function(e) { // code... }); note have used document here examp...

java - No Persistence provider for EntityManager named (Hibernate) -

i'm trying run sample jpa based project. error title time. i looked here: no persistence provider entitymanager named but found no working solution there. here pom.xml: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>~path.example</groupid> <artifactid>example</artifactid> <version>1.0-snapshot</version> <dependencies> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.6</version> </dependency> <dependency> <g...