Posts

Showing posts from June, 2014

java - Why can we not combine all the constructors, why must there be three overloaded constructors in typical inheritance cases? -

public class circlegeometricobject extends geometricobject { private double radius; public circlegeometricobject() {} public circlegeometricobject(double radius) { this. radius = radius; } public circlegeometricobject(double radius, string color, boolean filled) { this. radius = radius; setcolor(color); setfilled( filled); } } if wanted reduce code duplication below (add null checking though). it's possibly on top example, constructors lots of code can useful reduce duplication. public class myclass { private double radius; public myclass() { this(null, null, null); } public class myclass(double radius) { this(radius, null, null) } public class myclass(double radius, string colour, boolean filled) { this.radius = radius; setcolour(colour); setfilled(filled); } } ** edited change double double allow null

c# - AppHarbor - /order/rpc.ashx(1): error ASPPARSE: Could not create type 'web.order.rpc' -

this first attempt @ getting project running on appharbor the solution references number of other project dlls. build works locally , using git push appharbor. i message build fails: /order/rpc.ashx(1): error aspparse: not create type 'web.order.rpc'. [httpparseexception]: not create type 'web.order.rpc'. at system.web.ui.simplewebhandlerparser.gettype(string typename) at system.web.ui.simplewebhandlerparser.gettypetocache(assembly builtassembly) .... at system.web.compilation.buildmanagerhost.precompileapp(clientbuildmanagercallback callback, list`1 excludedvirtualpaths) at system.web.compilation.clientbuildmanager.precompileapplication(clientbuildmanagercallback callback, boolean forcecleanbuild) at system.web.compilation.clientbuildmanager.precompileapplication(clientbuildmanagercallback callback) at system.web.compilation.precompiler.main(string[] args) the source code pretty simple: namespace web.order { public class rpc : ihttphandl

c++ - Step line when debugging multithreaded application -

based on question "step over" when debugging multithreaded programs in visual studio , consider following scenario: thread running code starts thread b , keep going until point thread needs result of thread b. sake of sanity, let's assume following scheme: thread line 1 // <---- starts thread b line 2 line 3 // <---- breakpoint line 4 line 5 // <---- wait thread b thread b line 1 line 2 // <------ when code breaks, stoped here line 3 line 4 what happens when 1 click on "step over" button? i can think of 3 things: a go line 4. b stays in line 2 until "continue" button pressed. a go line 4. b go line 3 a go line 4. while don't stop @ line 4, b keeps going indefinitely. stop again, b stops. means b can in line 4 or exited while going line 3 4. if asked guess, i'd choose option 3. following line, there's way debug threads line line option 2? i'm asking in terms of there

How do I properly determine if my client is still connected to the server with C sockets? -

i have client connected server via c berkeley sockets. (try to) periodically check see if connection still valid calling recv() on socket msg_dontwait , msg_peek. however, i'm finding call returns eagain both when connection down in cases (e.g., after connection's interface shut down) , when there no data read. hence, there no way me distinguish whether connection still valid or not using method. here's function: /* return 1 if still connected, 0 otherwise */ int still_connected() { int nbytes_recvd = 0; char buf[2]; int err; nbytes_recvd = recv(fd,buf,sizeof(buf),msg_peek|msg_dontwait); err = errno; if ( nbytes_recvd == 0 ) { return 0; } else if ( nbytes_recvd < 0 ) { if ( (err == enotsock) || (err == enotconn) || (err == einval) || (err == econnrefused) || (err == ebadf) || (err == eopnotsupp) ) { return -1; } }

a client/server program using java won't work -

i'm trying create client/server program java. when client connect server, server show him message enter first value when user write first value server sends him message write sencd value when user write second value server show him list of operations ans wait until client write number of operation , server send him result of operation. when write program's code , run server , client, doesn't thing server blocked doing anything, client. this code tried : for client : import java.net.*; import java.util.scanner; import java.io.*; public class client { final static string adrss = "localhost"; final static int port = 1234; static socket s = null; public static void main(string[] args) { try{ scanner cn = new scanner(system.in); s = new socket(adrss, port); printwriter out = new printwriter(s.getoutputstream()); bufferedreader in = new bufferedreader(new inputs

java - Spring autowiring keeps JMockit mocks around for other tests -

i'm trying unit test class (let's say, "classundertest") , use of particular library class (let's call "helper"). i'm injecting mocked helper classundertest , using expectations check things out. public class testuseofhelper { @autowired classundertest classundertest; @mocked helperclass helper; [...] @before public void setup() throws exception { deencapsulation.setfield(classundertest, "helper", helper); } [...] @test public void test() { new expectations() {{ helper.dosomething(any); }}; classundertest.usehelper(); } so far, good. in other tests (same package, different file), i'm testing other aspects of classundertest want helper thing. public class testotherqualities { @autowired classundertest classundertest; [...] @test public void test() { result = classundertest.processsomething();

php - Saving multiple check boxes into one database field -

this question has answer here: how save multiple check-boxes data database? 2 answers i have number of check boxes relate 1 field in database. checked values recognised , put string value not saving database. table name , field name both correct. have ideas doing wrong? many in advance. *i understand code provided not secure please note testing implode function before apply actual code. my html code is: <tr> <td> <input type="checkbox" name="test[]" value="'apple'">apple<br> <input type="checkbox" name="test[]" value="'banana'">banana<br> <input type="checkbox" name="test[]" value="'pear'">pear<br> <input type="checkbox" name="test[]" value=&qu

zend framework - Autoloading phpunit test classes from another module in zf2 -

i trying reuse test classes module current module. directory structure looks like: home/ module.php config/ module.config.php src/ home/ <code files> test/ phpunit.xml bootstrap.php hometest/ <test code files> loader/ module.php config/ module.config.php src/ loader/ <code files> test/ phpunit.xml bootstrap.php loadertest/ <test code files> i running phpunit test classes in loader/test/ folder , need reuse classes home/test/hometest/model. i tried using in bootstrap file: autoloaderfactory::factory( array( 'zend\loader\standardautoloader' => array( 'autoregister_zf' => true, 'namespaces' => array( __namespace__ => __dir__ . '/' . __namespace__, 'hometest' => __dir__ . '/home/test/hometest',

How to hide / protect WCF URL in JQuery code -

i using jquery interact wcf rest service. somehow hide or secure url of service..but have no idea how this, help? function getmyuser() { var query = { "plastname": null }; query.plastname = "m"; var label = document.getelementbyid("idgetusersbylastname"); $(document).ready(function () { $.ajax({ type: "post", url: "//the url want hide", data: json.stringify(query), contenttype: "application/json; charset=utf-8", datatype: "text", success: function (data) { var zx = 5652; label.innerhtml = data; }, error: function (xmlhttprequest, textstatus, errorthrown) { var zx = 5652; msapp.execunsafelocalfunction(function () { label.innerhtml = xmlhtt

.net - Inheritance of C# attribute classes -

how inheritance of attribute classes work in c#? clarify, talking inheritance of attribute classes (i.e. base classes of system.attributes ), not classes happen have them attribute. for reason, cannot seem find on (my searches turn other meaning). for example, if have class attributea extends system.attribute : do have separately mark subclasses of attributea [attributeusage()] . (since system.attributeusage 's inheritance true , don't think will.) will allowmultiple=false on attributeusage of attributea prevent me having multiple subclasses of attributea attributes? edit: programmers can read code. [attributeusage(attributetargets.class, allowmultiple=false)] class attributea { } class attributeb : attributea { } class attributec : attributea { } [attributeb] [attributec] class foo { } does work? you can control behavior using named parameter inherited attributeusageattribute. [attributeusage(attributetargets.class, allowmultiple = fal

css - Background image outside of box on horizontal li items -

i understand background images cannot go outside box of element. however, case: i have horizontal list each list item should have hover effect little arraw sits atop item. positioning background won't work list items high text. positioned outside box gets cut off. i read solution additional element within each list item holds image. is there way change height of list item e.g. making box higher background image stay within box? is answer looking for? http://jsfiddle.net/fmpeyton/g5vvj/1/ html: <ul> <li><a href="#">page1</a></li> <li><a href="#">page2</a></li> <li><a href="#">page3</a></li> <li><a href="#">page4</a></li> <li><a href="#">page5</a></li> </ul> css: li{height: 50px; width:30px; margin:0 10px; float:left; list-style:none;} li:hover{background:

java - What do I do in order to make my Madlibs program accessible from this log in/password program? -

(first post on stack, woopee!) wrote madlibs program takes in user input, , makes story out of it. made user log in program want test using mad libs program. works fine, there 1 problem , i'll go through it. problem starts out log in screen. once use input proper keywords(dodo , foo), log in screen logs in, turns off, , calls madlibsgui program. here's problem: when this, reason madlibsgui program spawns 2 windows. have suspicious problem lies in madlibsgui's main method . i've tried fixing already, , hasn't seemed work. program works fine, 2 windows bother me. i'll post both code classes below read , at. both simple (i'm beginner programmer), shouldn't have of problem them. if have additional comments or corrections, please don't hesitate correct them. loginscreen: package passwordprogram; import java.awt.borderlayout; import java.awt.color; import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.event.actionev

php - How can I re-parse an XML document at set intervals? -

i have built area on client's website displays song playing, parsed xml file via php. however, client wants song auto-refresh instead of him having manually refresh page. i played around parsing file using jquery.get() , .ajax(), because of way xml file structured, seems though can artist , name squashed 1 string, or when try specific returns [object object]. i haven't tried tackle having song's length calculated , refresh feed based on length. may not seeing apparently such issue me. any or general guidance appreciated. example working php code (obviously, non-ajax): <?php $recentlyplayed = simplexml_load_file('http://publicapi.streamtheworld.com/public/nowplaying?mountname=abcdfm&numbertofetch=1&eventtype=track'); $tracktitle = $recentlyplayed->{'nowplaying-info'}[0]->property[1]; $trackartist = $recentlyplayed->{'nowplaying-info'}[0]->property[0]; echo "<h6>" . $trackartist . &qu

generator - Negative lookahead in LR parsing algorithm -

consider such rule in grammar lr-family parsing generator (e.g yacc, bison, etc.): nonterminal : [ lookahead not in {terminal1, ..., terminaln} ] rule ; it's ordinary rule, except has restriction: phrase produced rule cannot begin terminal1, ..., terminaln . (surely, rule can replaced set of usual rules, result in bigger grammar). can useful resolving conflicts. the question is, there modification of lr table construction algorithm accepts such restrictions? seems me such modification possible (like precedence relations). surely, can checked in runtime, mean compile-time check (a check performed while building parsing table, %prec , %left , %right , %nonassoc directives in yacc-compartible generators.) i don't see why shouldn't possible, don't see obvious reason why useful. have example in mind? the easiest way grammar transform mention in parentheses. make larger grammar, won't artificially increase number of lr states. the basic transfor

php - Form element validation based on other form element -

i'm rendering form add class (course) database. class has starttime , endttime. both time of day fields. created fieldset class: <?php namespace admin\form; use zend\form\fieldset; use zend\inputfilter\inputfilterinterface; use zend\inputfilter\inputfilterproviderinterface; class artclassfieldset extends fieldset implements inputfilterproviderinterface { public function __construct() { parent::__construct('artclass'); $this->add(array( 'name' => 'dayofweek', 'type' => 'zend\form\element\select', 'options' => array( 'label' => 'day of week:', 'value_options' => array( 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday',

asp.net mvc - CRUD operation to insert data -

my program compiles no errors unfortunately not insert data database. database table called "customers" great here code in model have: public actionresult apply() { return view(); } // // post: /default1/create [httppost] public actionresult apply(customer customer) { if (modelstate.isvalid) return view(); try { db.customers.add(customer); db.savechanges(); return redirecttoaction("apply"); } catch { return view(); } } then @ mvc have: <%@ page title="" language="c#" masterpagefile="~/views/shared/site.master" inherits="system.web.mvc.viewpage<greenenergygr.models.customer>" %> apply <form id="form1" runat="server"> apply <fieldset> <legend>customer</legend> <div class=&quo

java - Viewpager setCurrentItem() doesn't update onPageSelected() -

when swipe between questions, loads current page number correctly but when use next button, first click doesnt loads pagenumber ( mean onpageselected() doesnt work.) second , other clicks loads content loads 1 page previous. @override protected void oncreate(final bundle savedinstancestate) { super.oncreate(savedinstancestate); this.setcontentview(r.layout.activity_main); mpager = (viewpager)findviewbyid(r.id.pager); questionpageradapter madapter = new questionpageradapter(); mpager.setadapter(madapter); onpagechangelistener pagechangelistener = new onpagechangelistener() { @override public void onpagescrollstatechanged(int arg0) { } @override public void onpagescrolled(int arg0, float arg1, int arg2) { } @override public void onpageselected(int position) { tv.settext( mpager.getcurrentitem()+""); } }; mpager.setonpagechangelistener(pagechangelistener);

c - How to input pointer of a structure -

i writing program finding addition, multiplication , division of 2 rational numbers using structure , pointers. having problem inputting numbers pointers. how should code corrected? thanks! #include <stdio.h> struct rational { int nu; int de; }*p1,*p2,*p3; struct rational add() { p1->nu = p1->nu*p2->de + p1->de*p2->nu; p3->de = p1->de * p2->de; printf("%d\n--\n%d\n",p3->nu,p3->de); } struct rational multiply() { p3->nu = p1->nu * p2->nu; p3->de = p1->de * p2->de; printf("%d\n--\n%d\n",p3->nu,p3->de); } struct rational divide() { p3->nu = p1->nu * p2->de; p3->de = p1->de * p2->nu; printf("%d\n--\n%d\n",p3->nu,p3->de); } int main() { int a,b,choice; printf("enter first rational number.\n"); scanf("%d%d",&p1->nu,&p1->de); printf("enter second rational number.\n");

performance - Ackermann very inefficient with Haskell/GHC -

i try computing ackermann(4,1) , there's big difference in performance between different languages/compilers. below results on core i7 3820qm, 16g, ubuntu 12.10 64bit , c: 1.6s , gcc -o3 (with gcc 4.7.2) int ack(int m, int n) { if (m == 0) return n+1; if (n == 0) return ack(m-1, 1); return ack(m-1, ack(m, n-1)); } int main() { printf("%d\n", ack(4,1)); return 0; } ocaml: 3.6s , ocamlopt (with ocaml 3.12.1) let rec ack = function | 0,n -> n+1 | m,0 -> ack (m-1, 1) | m,n -> ack (m-1, ack (m, n-1)) in print_int (ack (4, 1)) standard ml: 5.1s mlton -codegen c -cc-opt -o3 (with mlton 20100608) fun ack 0 n = n+1 | ack m 0 = ack (m-1) 1 | ack m n = ack (m-1) (ack m (n-1)); print (int.tostring (ack 4 1)); racket: 11.5s racket (with racket v5.3.3) (require racket/unsafe/ops) (define + unsafe-fx+) (define - unsafe-fx-) (define (ack m n) (cond [(zero? m) (+ n 1)] [(zero? n) (ack (- m 1) 1)] [else (ack (- m 1) (a

regex - Possible to change the record delimiter in R? -

is possible manipulate record/observation/row delimiter when reading in data (i.e. read.table) text file? it's straightforward adjust field delimiter using sep="", haven't found way change record delimiter end-of-line character. i trying read in pipe delimited text files in many of entries long strings include carriage returns. r treats these crs end-of-line, begins new row incorrectly , screws number of records , field order. i use different delimiter instead of cr. turns out, each row begins same string, if use use \nstring identify true end-of-line, table import correctly. here's simplified example of 1 of text files might like. v1,v2,v3,v4 string,a,5,some text string,b,2,more text , more text string,b,7,some different text string,a,, should read r as v1 v2 v3 v4 string 5 text string b 2 more text , more text string b 7 different text string n/a n/a i can open files in text

html - get the latitude and longitude using javascript -

i have textbox in page gets location name , button text getlat&long . on clicking button have show alert of latitude , longitude of location in textbox . suggestion? please dont give me suggestion googleapis b'coz stage limitations after limit want pay this. try googleapis :- <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function myip(){ $("#btn").click(function(){ var geocoder = new google.maps.geocoder(); geocoder.geocode( { 'address': '#city'}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.ln

c++ - Issue with pushing a Struct object into queue -

i have structure , want create queue of struct. have problem pushing new element. please. #include <iostream> #include <queue> #include <deque> #include <list> using namespace std; struct node { node *left, *right; int key; }; queue<node> q; void updatelevel( node &n, int &level){ if(n.left!=null && n.right!=null){ level+=2; q.push(n.left); q.push(n.right); } else if(n.left!=null || n.right!=null){ level++; if(n.left!=null) q.push(n.left); if(n.right!=null) q.push(n.right); } }; void printtree(node root){ //if(root!=null){ q.push(root); node n; while(!q.empty()){ n =q.pop(); updatelevel(n,nextlevel); curlevel--; cout<<n.key; if(curlevel<=0){ cout<<endl; curlevel=nextlevel; nextlevel=0; } } //} }; int main() { node roottree; printtree(roottree); return 0; } i calling func

java - leading whitespace while using string.split() -

here's code using split string str = "1234".split("") ; system.out.println(str.length) ; //this gives 5 there whitespace added before 1 i.e str[0]=" " how split string without having leading whitespace. try this: char[] str = "1234".tochararray(); system.out.println(str.length) ;

java - Python sys.setprofile() in other lanuages -

i working on writing few profiles need formatted in way , on. looking ways write custom profilers in other lanauges. came across python's sys.setprofile method , hoping can point me in right direction finding sister functions or methods of doing same thing in following methods. python's sys.setprofile(profilefunc) method allows callback function called everytime function called , returned. makes easy write custom profile classes, goal write library allows easy profiling in many langues it, going made can run on production severs. php ruby java .net nodejs your favorite language (maybe there popular lanauge missed)

In java, when does object space die out, which is created by "new" operator -

i write java program, , wanna clear memory management in java. example, method this: public void example1() { byte[] bytes = new byte[100]; } after calling method, byte[] space created "new" in heap space die out? 2th example this: public byte[] example2() { byte[] bytes = new byte[100]; return bytes } also question, byte[] space die out in situation? the space garbage collected when garbage collector runs , detects there no more references it. in case if code concerned reference ceases exist when method exits, space eligible collection onwards.

Android: How do I randomly place an array of buttons in an activity? -

i wondering how "randomly" place array of buttons in relativelayout? is possible space buttons around entire view? thanks help! tried using setx() , sety() float numbers , i'm unsure how place buttons in proportion size of screen. you can add layout margins buttons. margins interpreted not relative each other frame, in fact position buttons. to set margins have set view's layout params: relativelayout.layoutparams params = new relativelayout.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content); random random = new random(); params.leftmargin = random.nextint(100); params.topmargin = random.nextint(100); button.setlayoutparams(params); however may cause buttons overlap, or outside activity, it's best not use entirely random values positions perform checks overlapping , set random ranges according device resolution , button size. to device display size: display display= activity.getwindowmanager().getdefaultdisplay(); int widt

python - Flask unit tests with SQLAlchemy and PostgreSQL exhausts db connections -

i'm running suite of straightforward test cases using flask, sqlalchemy, , postgresql. using application factory, i've defined base unit test class so: class basetestcase(unittest.testcase): def setup(self): self.app = create_app() self.app.config.from_object('app.config.test') self.api_base = '/api/v1' self.ctx = self.app.test_request_context() self.ctx.push() self.client = self.app.test_client() db.create_all() def teardown(self): db.session.remove() db.drop_all(app=self.app) print db.engine.pool.status() if self.ctx not none: self.ctx.pop() all goes few unit tests, until: operationalerror: (operationalerror) fatal: remaining connection slots reserved non-replication superuser connections it seems there 1 connection in pool (db.engine.pool.status() each test shows: pool size: 5 connections in pool: 1 current overflow: -4 current checked

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -

i love facebook dashboard: pue & wue. beautifull can point out if there open source or commercial product offer similar style? here link https://www.facebook.com/forestcitydatacenter?sk=app_288655784601722&app_data so read through 29,888 lines of javascript ya.. biggest js file i've ever seen. looks make graph using variety of tools, including tween.js . it'd fascinating chat whoever made it. code wheel graph object starts @ line 27,266 text var graphcomponent = class.extend({ . can find source @ https://www.fbpuewue.com/assets/application-3a3af20f7fa3591229c79442ae3d1c26.js . sorry if dissapoints it's not awesome plugin can use :/ share pain. let me know if have questions :)

videoview - How to seek Previous video when backing video in 0:0 Android? -

Image
i use videoview play video , use seekto seek in video. , want when use mediacontroler , pree key , arrived 00:00 video stoped , previous video begging play video. how find video 00:00 time ?

python - Get characters of a string (from right) -

i'm looking best way file name of variable looks that: = 'this\is\a\path\to\file' print a[-4:] i'm trying 'file' extracting last 4 letters print a[-4:] result is: ile if make print a[-5:] get: ofile i guess python has problem backslash, escaping did not help. how solve this? way or there more performant way "file" searching '\' right left? \f single character (form-feed) in python. try doubling backslashes: a = 'this\\is\\a\\path\\to\\file' or, equivalently: a = r'this\is\a\path\to\file' after print a[-4:] print file .

Android - how to open an audio-stream url with an external app? -

i want give user choice of opening audio stream url audio player have installed. the following code works far user getting list of installed audio apps , can choose between then. intent intent = new intent(); intent.setaction(intent.action_view); intent.setdataandtype(uri.parse(stream.getaudio()), "audio/*"); startactivity(intent); but open intent lives inside app only. therefor playback stop if user closes app. how can change behaviour not new activity started whole app launched , detached app. i guess it's because audio player opened in same task stack of app. try intent.flag_activity_new_task start new task, like: intent.setflags(intent.flag_activity_new_task); see tasks , stack learn more.

add the values of two different associative arrays in php . display unique key-values too in the result array -

this question has answer here: how sum values of array of same key? 13 answers i need merge 2 associative arrays may or may not contain same key,if key same values need added , stored in resultant array $array1 = array( 'a' => 5, 'b' => 10, 'c' => 6, 'k' = > 10 ); $array2 = array( 'a' => 100, 'c' => 200, 'd' => 30, 'k' => 10 ); how add above 2 associative arrays , receive following output/associative array - $array2 = array( 'a' => 105, 'b' => 10, 'c' => 206, 'd' => 30, 'k' => 20 ); try $array1 = array( 'a' => 5, 'b' => 10, 'c' => 6, 'k' => 10 ); $array2 = array(

POS Receipt Printing From Rails App to Star Micronics TSP 143U -

ok, starting seem bit of hopeless situation might throw question out there see if can lucky. have star micronics tsp 143u receipt printer connected lantronix xprintserver home edition enable airprinting receipt printer on local network. 90% of setup works -- have rails webapp creates receipt , formats using css print media query, star printer gets plugged in via usb xprintserver , found , configured within 30 seconds automatically, , of ios devices can detect printer , initiate print jobs. print job use javascript document.print() call on page load. everything works fine, except when print job initiated, printer prints needed , not stop feeding paper or cut receipt. there way can format html document using css induce printer stop printing after last line of text? alternatively, there way can send esc/p2 escape command printer on local network mobile safari browser (according docs cut command esc d)? this matt star micronics tech support. tsp100 not support print ser

ef code first - Prevent Entity Framework from adding duplicated keys in migration with table per type inheritance -

i have simple model using table per type inheritance entities. problem when generate migration using add-migration, creates duplicated index on child class' primary key. class definitions: class product { [key] public int productid { get; set; } public int value { get; set; } } class service : product { public int othervalue { get; set; } } and in context, specify table names both classes class productcontext : dbcontext { virtual public dbset<product> productset { get; set; } virtual public dbset<service> serviceset { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<product>().totable("product"); modelbuilder.entity<service>().totable("service"); } } running add-migration results in following: public override void up() { createtable( "dbo.product", c => new {

how to make multiple ajax query work on all browsers with jQuery -

am working on project , found little problem ajax request finding hard fix. want perform multiple ajax requests, in mean: need perform ajax request, , if successful, perform ajax request within success handler. here sample of code: var result; $.post('make_payment.php',{password:pass,amount:50},function(data){ result=data; if(result=='success'){ $.ajax({ type:'post', datatype:"json", url:"save_info.php", success: function(data){ if(data.result=='success'){ alert('success'); } }, error:function(){ alert('failed'); } }); } }) this works pretty on mozilla firefox , google chrome, not work on internet explorer , apple safari. pls need assistance on how make work on browser. trying using datatype:"jsonp" instead of datatype:"json" . i'm not sure of reason long had

sql server 2008 - SQL query: help needed -

i need sql query, have tried replicate actual problem creating simple example: parents table: id name parent_id 1 parent1 null 2 parent2 1 3 parent3 1 4 parent4 3 5 parent5 3 6 parent6 5 7 parent7 5 relatives table: id name parent_id 1 relative1 2 2 relative2 3 3 relative3 4 4 relative4 5 5 relative5 7 parents table has list of parents have parents themselves. relatives table has list of relatives parent_id column. how find relatives of parent3 including 'desendants' of parent3, i.e. query should return following relatives table: relative2 (because parent id 3) relative3 (because parent id 4 parent id 3) relative4 (because parent id 5 parent id 3) relative5 (because parent id 7 parent id 5 parent id 3) i'm using sql server 2008. hope makes sense, appreciated. try this ;with cte ( select [id], [name] parents [name] = 'parent3' union select t1

How to manually install JAutodoc in eclipse kepler? -

i not have access internet eclipse can not add software using update sites. have tried several different methods none seems working. i using jboss dev studio version of kepler, figured might general eclipse question. tried help- install new software - add... - browse zip file , "could not find jar:file:/blahblahblah/jautodoc_1.10.0.zip!/" nothing. tried unzipping end eclipse/dropins/jautodoc_1.10.0/[features | plugins followed restart. nothing. tried unzipping end eclipse/dropins/[features | plugins] followed restart. still nothing. what definitive way this? follow these steps installation: download jautodoc_1.11.0.zip file : http://jautodoc.sourceforge.net/index.html#download unzip jautodoc_1.11.0.zip file eclipse folder. verify following files copied: plugin folder : net.sf.jautodoc.velocity_1.11.0.jar net.sf.jautodoc_1.11.0.jar features folder : net.sf.jautodoc.feature_1.11.0 restart eclipse. jautodoc feature should available in

nestacms - Filter articles by category with Nesta CMS -

we want display article summaries given category. standard index page build this: %section.articles= article_summaries(latest_articles) but see no way of filtering articles category. ok figured out- list articles category, have assign pages given category , create actual category page each category- i.e. page named same category. for example, if page assigned categories dogs , cats ... categories: dogs, cats i'll need create new pages called dogs.haml , cats.haml , list articles categories standard code found in default page.haml template: %section.articles = article_summaries(@page.articles)

python - numpy matrix multiplication shapes -

this question has answer here: how multiplication differ numpy matrix vs array classes? 7 answers in matrix multiplication, assume a 3 x 2 matrix (3 rows, 2 columns ) , b 2 x 4 matrix (2 rows, 4 columns ), if matrix c = * b , c should have 3 rows , 4 columns. why numpy not multiplication? when try following code error : valueerror: operands not broadcast shapes (3,2) (2,4) a = np.ones((3,2)) b = np.ones((2,4)) print a*b i try transposing , b , alwasy same answer. why? how do matrix multiplication in case? the * operator numpy arrays element wise multiplication (similar hadamard product arrays of same dimension), not matrix multiply. for example: >>> array([[0], [1], [2]]) >>> b array([0, 1, 2]) >>> a*b array([[0, 0, 0], [0, 1, 2], [0, 2, 4]]) for matrix multiply numpy arrays: >>

asp.net mvc 4 - Web API Help pages - customizing Property documentation -

i have web api , added web api pages auto-generate documentation. it's working great methods parameters listed out, have method this: public sessionresult postlogin(createsessioncommand request) and, on page, listing command parameter in properties section. however, in sample request section, lists out of properties of createsessioncommand class. parameters name | description | additional information request | no documentation available. | define parameter in request body. i instead list of properties in createsessioncommand class. there easy way this? this should go addition @josh answer. if want not list properties model class, include documentation each property, areas/helppage/xmldocumentationprovider.cs file should modified follows: public virtual string getdocumentation(httpparameterdescriptor parameterdescriptor) { reflectedhttpparameterdescriptor reflectedparameterdescriptor = parameterdescriptor reflectedhttpparameterdescri

updates - NetSuite API - How to send tracking number back to Invoice or Sales Order? -

i'm integrating shipping solution netsuite via soap api. can retrieve shipaddress via searchrecord call. need send tracking number, service used, , cost netsuite. hoping can point me in right direction searching hasn't turned answers me. example xml great. im pretty pasting had external developer attempt implement response don't understand how setup envelope receive within ns on record...i think handling update post field: ' var = new array(); a['content-type'] = 'text/xml; charset=utf-8'; a['post'] = '/fedexnsservice/service1.asmx http/1.1'; a['content-length'] = data.length; a['soapaction'] = 'https://wsbeta.fedex.com:443/web-services/ship/returnfedexlable'; nlapilogexecution('debug', 'results',

c# - How to retain date and time in a variable? -

i have following code: button schedend = findviewbyid<button>(resource.id.buttonschede); schedend.click += schedend_click; } void schedend_click(object sender, eventargs e) { dialog dialog = new dialog(this); dialog.setcontentview(resource.layout.datetimepickertemplate); dialog.settitle("pick date , time"); timepicker tp = findviewbyid<timepicker>(resource.id.timepicker1); button butadd = findviewbyid<button>(resource.id.buttonadd); //tp.setontimechangedlistener(ontimechangedlistener: retain()); // tp.setis24hourview(new boolean(true)); butadd.click += butadd_click; //tp.setis24hourview(true); dialog.show(); } private void retain() { } void butadd_click(object sender, eventargs e) { edittext edittxt = findviewbyid<edittext>(resource.id.editschstart); edittxt.text = e.tostring(); } i have custo

android - Find exact coordinates of a single Character inside a TextView -

currently i'm using paintobject.measuretext(textcopy.substring(0,i)) while iterating through copy of textview's text. example, measuretext("abc".substring(0,1)) give me relative x coordinates of 'b'. y coordinate layout.getlinetop() . working not accurate x coordinates non-monospaced fonts. can calibrate little, on each device works differently. the best solution can think of overwrite class responsible drawing textview on screen and, hopefully, coordinates of each character drawn screen. does know class need overwrite accomplish this? or maybe other creative solution? well seems sort of bug of paint.measuretext() or other deeper class. have finally found way around it: layout.getprimaryhorizontal(int offset) this easy. iterate through layout using length of text uses. it return the x of character regardless of line position. lines i'm still getting layout.getlinetop() . way, if using layout.getlinetop() , note there strange

audio - ffmpeg error when cutting video (aac bitstream error) -

i'm trying use ffmpeg cut out 5 minute chunk video. reason on particular video error "aac bitstream error". resulting video 5 minutes long no audio or video. ffmpeg -i testvideo.mp4 -ss 00:05:00 -t 00:10:00 -c:v copy -c:a copy testvideo_5min_test.mp4 ffmpeg version n-55540-g93f4277 copyright (c) 2000-2013 ffmpeg developers built on aug 14 2013 12:15:34 gcc 4.3.2 (debian 4.3.2-1.1) configuration: --enable-libx264 --enable-gpl --enable-shared --enable-libfaac --enable-nonfree libavutil 52. 42.100 / 52. 42.100 libavcodec 55. 28.100 / 55. 28.100 libavformat 55. 13.102 / 55. 13.102 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 82.100 / 3. 82.100 libswscale 2. 4.100 / 2. 4.100 libswresample 0. 17.103 / 0. 17.103 libpostproc 52. 3.100 / 52. 3.100 input #0, mov,mp4,m4a,3gp,3g2,mj2, 'testvideo.mp4': metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 creation

c - why gdb show wrong variable value? -

this question has answer here: gdb prints wrong values when modifying arguments 3 answers i have simple program: #include <stdio.h> void func(int i) { = 1; printf("%d\n", i); } int main(int argc, char *argv[]){ func(0); return 0; } and now: gcc test.c -g -o test gdb test (gdb) b main breakpoint 1 @ 0x400543: file test.c, line 9. (gdb) run starting program: /tmp/test breakpoint 1, main (argc=1, argv=0x7fffffffe458) @ test.c:9 9 func(0); (gdb) s func (i=0) @ test.c:4 4 =1; (gdb) p $1 = 0 (gdb) n 5 printf("%d\n", i); (gdb) p $2 = 0 (gdb) program works fine, shows "1", why gdb shows me "0" value? debian wheezy. i observed on gcc-4.7, gcc-4.6. on gcc-4.4 ok. this bug fixed if compile -fvar-tracking . question tighter version of this question , references bug report o

node.js - Dust.js using the same partial many times on the same page -

i have parent template receives following context: { users: [ { userid: "18288128", group: "user 1 group name", uservideos: [{ id: 1, name: "video1"}, { id: 2, name: "video2"}, { id: 3, name: "video3"}] }, { userid: "1232412", group: "user 2 group name", uservideos: [{ id: 4, name: "video93"}, { id: 5, name: "video384"}, { id: 6, name: "video483"}] }, { userid: "1231231", group: "user 3 group name", uservideos: [{ id: 7, name: "videoa"}, { id: 8, name: "videob"}, { id: 9, name: "videoc"}] } ] } this parent template: {#users} {! here want add partial video_list passing correct parameters (uniqueid, groupname

atmel - Issues in C with including time.h? -

i have file in massive project i'm working on called timekeeper.h (and .c) --------------edit---------------fixed bool thing still broken though-------------- #ifndef timekeeper_h_ #define timekeeper_h_ #include <time.h> #include <stdbool.h> bool isafter(time_t time); void settime(char seconds, char minutes, char hours, char day, char month, char year); void tickseconds(void); time_t getcurrenttime(void); time_t createtime(char seconds, char minutes, char hours, char day, char month, char year); void starttime(void); time_t addseconds(int seconds, time_t time); long timeremaining(time_t time); void rtc_set(char seconds, char minutes, char hours, char days, char months, char year); #endif when attempt build project, there bunch of errors in file (and file using time.h). here's of errors in timekeeper.h: expected ')' before 'time' line 6 expected '"', ',', ';','asm', or