Posts

Showing posts from August, 2014

java - glDrawBuffers should have flipped IntBuffer? -

i have following code: intbuffer drawbuffers = utils.createintbuffer(2); int bfs[] = {gl30.gl_color_attachment0, gl30.gl_color_attachment1}; for(int = 0; < 2; i++) drawbuffers.put(bfs[i]); drawbuffers.flip(); gl20.gldrawbuffers(drawbuffers); if flip intbuffer int status = gl30.glcheckframebufferstatus(gl30.gl_framebuffer); don't equal gl_framebuffer_complete , if don't flip status right, black texture instead of desired texture, looked throught code on , on 2 days now, best bet part of code somehow wrong, rest seems ok. should intbuffer flipped before using in gldrawbuffers(intbuffer) ? yes, buffers should flipped before being passed lwjgl. the underlying gl api expects array functions take java buffer. size of array parameter in gl's c language bindings, hidden in java because lwjgl calculates difference between current position , end position. unless flip java.nio.buffer , sets "current" position beginning of buffer,

dynamic - Refer to an excel named range on another sheet using indirect -

let's have 3 sheets (let's sheet1 , sheet2 , sheet3 ). sheet1 , sheet2 contain each sheet-level range named myrange . in sheet3 , if want access myrange sheet1 , able use ='sheet1'!myrange . but now, want sheet3 contain generic code , able refer either sheet1 or sheet2 . expect able achieve same thing using =indirect("'" & mysheetname & "'!myrange") however, error #ref when that. what do wrong ? how can work around ? if myrange consists of multi-row, multi-column range, make sure pressed ctrl-shift-enter when entered =indirect("'" & mysheetname & "'!myrange") . if forget use ctrl-shift-enter , #value error. however, stated have #ref . using code single-cell range, result looking for. way can #ref error using wrong sheet name. suspect problem. check sheet name , repost more detail if still doesn't work.

mysql - SQL foreign key restraint referencing information_schema -

is possible "constrain" columns in 1 table "reference" columns views in information_schema in way (it needn't proper foreign key constraint, hence scare quotes)?-- need minimally-intrusive way of adding arbitrary metadata existing column data (e.g. add "comments" e.g. value shop.cheeses.name shop.cheeses.id = n ), , thought of defining table such: create table shop.metadata ( `table_schema` varchar(64) not null, `table_name` varchar(64) not null, `column_name` varchar(64) not null, `record_id` int(11) unsigned not null, `comments` text not null, /* show purpose of table */ primary key (`table_schema`, `table_name`, `column_name`, `record_id`), foreign key (`table_schema`, `table_name`, `column_name`) references information_schema.tables(`table_schema`, `table_name`, `column_name`) ); however, statement returns error 1215 (hy000): cannot add foreign key constraint , presumably because table_schema , table_name , co

java - How to select an remembered item in the text box with Selenium webdriver? -

how select remembered item in text box selenium webdriver? hashmap<string, arraylist<integer>> map = new hashmap<string, arraylist<integer>>(); for(int i=0; i<strs.length; i++){ char[] arr = strs[i].tochararray(); arrays.sort(arr); string t = string.valueof(arr); if(map.get(t) == null){ arraylist<integer> l = new arraylist<integer>(); l.add(i); map.put(t, l); }else{ map.get(t).add(i); } please try below: webdriverwait wait = new webdriverwait(driver,30); driver.findelement(by.id("product_quickaddinput")).sendkeys(“00006692”); webelement element = driver.findelement(by.xpath("//div[@id='div_0']")); wait.until(expectedconditions.elementtobeclickable(element)); element.click();

twitter bootstrap - Boostrap CDN with 16-columns instead of 12 -

i want use latest bootstrap cdn, defaults 12 column layout. way customize 16 col layout download , host files yourself? edit: i'm asking how bootstrap through cdn. use bootstrap cdn https://cdnjs.com/ , works great, except 12-col layout. there 2 options this. you override bootstraps grid system own css file. <link rel="stylesheet" href="/cdn/path/to/bootstrap.css" /> <link rel="stylesheet" href="/my/path/overide_bootstrap.css" /> this can tedious task , not recommend doing way. customize bootstrap , use own version if go http://getbootstrap.com/customize/ can customize , download customized version of bootstrap. looking located @ http://getbootstrap.com/customize/#grid-system . once has been downloaded have few options: serve files own project. use free cdn service there multiple cdn services can use, such cloudflare ( https://www.cloudflare.com/features-cdn ) or can use cdnjs ( https://github.

How to use ILNumerics function csvread to load complex array from a csv file -

i want load csv format data file function csvread. data in complex format. example, looks "36.151-202.64i,236.74+2.1788i,26.234+201.94i, ...." when call csvread ilnumerics, can first column data. other data zeros. here simple 2 lines of code. var inputdatafile = file.readalltext(@"c:\temp\input.txt"); ilarray datcomplex = csvread(inputdatafile); please help. it popular request, , working on it. upcoming version support reading complex numbers , arbitrary formatted elements in csv files. stay tuned!

salesforce - Schedule a batch at certain hours -

i made schedulable batch want run @ hours, let's 6, 12 , 18. i'm writting hours in custom setting cs_schedule__c. how can call cs apex , hours? thanks in advance. here page outlining how retrieve custom settings in apex depending on if it's list or hierarchy custom settings. as far scheduling, can in apex if wish, so: classtoschedule schcls = new classtoschedule(); string sch = '20 30 8 10 2 ?'; string jobid = system.schedule('name of job', sch, schcls); the sch string cron expression represent time runs. check out cron expression builder more info. instead of using numbers build string data in custom setting.

parsing - How to parse this information from a string? -

country residents area capital andorra 71201 468 andorra la vella italien 58133509 301230 rom san marino 29251 61 san marino i need store information (capital, residents, area, capital) in different variables. how go parsing this? notice there spaces in names. i have tried reading each token ( scanner.next() ) fails when there spaces in capital or country name. i have tried reading each line , parsing can't figure out way parse correctly since there sometime spaces in names. (i used indexof() , substring() ) this part of bigger file there no spaces in residents or area field in entire field. my try: while(scanner.hasnext()){ string info = scanner.nextline(); //parse string int nameindex = info.indexof(" "); system.out.println(info.substring(0,nameindex)); int resindex = info.indexof(" ", nameindex); } i hope have multiline string per question title. why don't use rege

Database: Are there any vendors support column level locking? -

i'm studying database mechanism , see there 2 mechanisms: table level locking , row level locking . don't see column level locking , when google, see no document tell except link: database locking . in link: a column level lock means columns within given row in given table locked. form of locking not commonly used because requires lot of resources enable , release locks @ level. also, there little support column level locking in database vendors. so, vendors support column level locking ? , can tell me more detail, why column level locking requires lot of resources row level locking . thanks :) a lock cannot, in , of itself, require anything. it's abstract verb acting on abstract noun. why should locking column cost more locking byte, or file, or door? wouldn't put lot of stock in link. the answer question lies in why locks exist -- protect -- , how dbmss engineered. one of primary jobs of dbms manage concurrency: give each use

Modified dependencies in python package do not show up -

in python package have, in setup.py modified dependencies removing condition on version number: setup( name='mytool', version='0.1.5', author='myname', author_email='myname@myname.com', packages=['mytool'], scripts=['bin/my_tool.py'], url='https://pypi.python.org/pypi/mytool', license='license.txt', description='this tool.', long_description=open('readme.txt').read(), install_requires=[ "scipy", "numpy", "prettytable" ], ) i ran: $ python setup.py sdist $ python setup.py sdist upload but when run pip , refers previous requirements: $ sudo pip install mytool requirement satisfied (use --upgrade upgrade): mytool in /usr/local/lib/python2.7/dist-packages requirement satisfied (use --upgrade upgrade): scipy>=0.7.0 in /usr/local/lib/python2.7/dist-packages (from mytool) requirement satisfied (

html - Why do my image links not work on iphones and ipads? -

aware can't have link rollovers / hovering on ipads , iphones have tried changing rollover backgrounds clickable images iphones , ipads links still don't work on them. can see why these won't work. here css used target ipads: /* ipad [portrait + landscape] */ @media screen , (min-device-width: 768px) , (max-device-width: 1024px) { div.website_bck img { display: block!important; width: 100%!important; } div#hi_hats, div#marbella, div#bcl, div#chinahouse, div#suponix, div#pa, div#upwardmb, div#salon, div#fasbet, div#wrayent, div#box, div#bcl_logo, div#greenseeds, div#lilyrose, div#stationery_suponix, div#stationery_bcl, div#stationery_charmel, div#stationery_box, div#adverts_digital_betfred, div#adverts_digital_itvbets, div#adverts_digital_bingo, div#adverts_digital_casino, div#adverts_digital_freebet, div#adverts_print_betfred1, div#adverts_print_betfred2, div#adverts_print_bingo, div#adverts_print_hi_hats, div#adverts_print_fasbet, div#other

python - Plotting contours from data csv -

i have data within csv file temperature, x, y , z points arranged in columns. z points can negated remains 0 through data acquisition. i'd obtain contour plot of data. my problem same this got redirected other threads still couldn't figure out going on. edit: here's unfinished code should open data? don't know go here. import numpy np import matplotlib.pyplot plt matplotlib.mlab import griddata import csv data = np.genfromtxt('tempcontour0.csv', delimiter=',', dtype=[('t',float),('x',float),('y',float),('z',float)],usecols=(0,1,2)) t=data['t'] x=data['x'] y=data['y'] z = np.zeros((len(x),2)) z[:,0] = x z[:,1] = y plt.contour() plt.show() the data file so: t,x,y,z 316.002,0,0,0 309.314,0.00839113,0,0 309.67,0.0172418,0,0 310.34,0.0265772,0,0 310.903,0.0364239,0,0 311.558,0.0468098,0,0 312.704,0.0577645,0,0 313.582,0.0693192,0,0 314.582,0.0815067,0,0 316.2,0.0943616,0,0 317.391,0

linux - Update cURL in a server with Debian 7.8 Wheezy -

i have server debian 7.8 wheezy , need --tlsv1.2 option in curl, comes in version 7.34 or greater. problem that: curl --version >> curl 7.26.0 and 7.26.0 seems latest version in wheezy. as commented svlasov , here answer: https://serverfault.com/a/22418

Linking Marketo Custom Object to Lead via SOAP -

how link custom object created via marketo's soap api existing lead? in custom object, can define 1 of fields 'link'. in web interface , when select 'link', reloads dialog , gives option select linked object type (lead) , field link (id). when create object using soap api link field this, can give custom object lead id link it.

c++ templates dependent on input from file -

i have complicated c++ scientific code, uses multiple libraries. imagine there 5 different types of libraries, linear solver, integration tool, etc. each library type there several different libraries same thing, have different internal implementation. in fact, every library wrapper class implemented, such libraries of same type have same interface. now, want give software user. want user able select libraries want use after code compiled. done means of input file. the problem coding in main program. when coding library selection, end using nested ifs, explicitly coding every possible combination of libraries, conditioned on parameters read file. wondering if there tidy way this. you can't implement templates dependent in input files, since template types resolved in compilation, not runtime. the tidy way polymorphism (also, elegant way ;d). define base class defines interface each implementation, create children classes each 1 it's own implementation, , th

c++ - Single make and parallel tests in Travis -

i need run once: autoreconf -i mkdir build && cd build ../configure make and run tests in different folders: make check -c path1 make check -c path2 the tests can parallelized matrix feature: language: - cpp compiler: - clang env: - test_path=path1 - test_path=path2 install: - autoreconf --install - mkdir build && cd build - ../configure - make script: - make check -c $test_path the problem is: install step runs twice , e.g.: install + test path1 install + test path2 is there way achieve like: install (runs once) run 2 jobs tests (the script part of travis config): test path1 test path2

json - django rest framework view with merged results from different object serializers -

having following models class treelifephase(dbordered): name = models.charfield(max_length=200) def __unicode__(self): return self.name class treewidth(dbordered): name = models.charfield(max_length=200) def __unicode__(self): return self.name and many more this, contain editable attributes of tree objects. select field on ui want have available treelifephases , treewidths 1 query - have json result looks like { "treelifephases": [ { "id": 1, "name": "young" }, { "id": 2, "name": "medium" }, { "id": 3, "name": "old" } ], "treewidths": [ { "id": 1, "name": "10-20cm" }, { "id": 2, "name&quo

android - How to add empty spaces after custom listview? -

my problem, in custom listview last element 'select' button overlap cart icon. my question, how add empty space after end of custom listview? you can set linear layout listview. , can use linear layout footer(cart icon). when setting linear layouts, can add layour weights ,so can arrange listview , cart icon clearly. if want more clarifications inform me

javascript - Firefox screen flickers when resizing -

i facing flickering issue, on re-sizing, firefox web browser. think because of use of svgs on page. tried adding transition css property referring following links, didn't help. 1. https://css-tricks.com/forums/topic/can-i-stop-flickering-on-hover/ . 2. https://developer.mozilla.org/en-us/docs/web/guide/css/using_css_transitions any or starting reference appreciated. thank you. new css. 1 more thing, screen not flicker in chrome or ie. hope information helps , not stupid question.

generics - How is ArrayList represented internally in Java Collection Framework.? -

i going through lectures of algorithms on coursera robert sedgewick.i bit confused when mr.robert pointed out 1 cannot use generics arrays not allowed. arraylist in collection framework uses arrays internally , generic datatypes allowed.i mean can following: arraylist<integer> list = new arraylist<integer>(); one hack pointed out this: public class fixedcapacitystack<item>{ private item[] s; private int n = 0; public fixedcapacitystack(int capacity) { s = (item[]) new object[capacity];} //this hack he mentioned ugly hack , must avoided , produces warning during compilation. my question is: 1.) how arraylist internally represent various generics types? 2.) if (assumed) use hack mentioned above why doesn't produce warning when compile program arraylist? 3.) there better way apart cast above? per source: 1 - arraylist stores items in object[] , , casts value when retrieving individual elements. there's @suppresswarnings(

c - Stirling approximation producing a different output than expected -

so new c , learning syntax. have come across problem though. trying prove stirlings approximation where ln (n!) = n ln (n) - (n) so when make print statements within code test whether each element of array producing output of array number want be. it's far it. #include <stdio.h> #include <stdlib.h> #include <math.h> double * natural_log (); /* obtain natural log of 0 100 , store each value in array */ double * approximation (); /* use sterling approximation caluculate numbers 0 - 100 , store in array */ double * difference (); /* calculate difference between arrays */ double * percentage (); /* calculate percentage of difference , return array */ int main () { natural_log (); /* approximation (); */ return 0; } double * natural_log () { static double natural_array[101]; /* set array */ int i; /* set integer increase array value */ natural_array[0] = 0.0; /* set first value in array */ natural_array[1] = log(2); dou

javascript - $.post inside html2canvas? -

Image
i have 2 functions: number one html2canvas($("#screenshot"), { onrendered: function(canvas) { $('.ha').append(canvas); } }); number two $.post("save.php",{ xcv : canvas }, function(data){ if (data == 1) { $('.cropped').empty(); $('.cropped').append('<img src="' + data + '">'); $('.cropped').append('<h2>is okay?</h2>'); } else { alert(thecanvas); } }); function number 1 takes screenshot of div-container "screenshot" , shows in div-class "ha". function number 2 should give canvas php file transform canvas pyhsical file. if successful php-file return "1" , post picture on page because "data" keeps filename. tried this: html2canvas($("#screenshot"), { onrendered: function(canvas) { $('.ha').append(canvas); $.post("save.php",{ xcv : canvas }, function(data)

c# - Alex FTPS getting callback from PutFile -

i'm using alex ftps upload file. result message putfile command. i see there filetransfercallback don't know how use exactly. using (ftpsclient client = new ftpsclient()) { // connect server client.connect(ftpserver, new networkcredential(ftpuser, ftppwd), esslsupportmode.credentialsrequired | esslsupportmode.datachannelrequested | esslsupportmode.implicit, new remotecertificatevalidationcallback(validatetestservercertificate) ); client.settransfermode(etransfermode.binary); // upload file myresult += client.putfile(filename, fi.name, filetransfercallback???); } how info filetransfercallback?

model view controller - Configure Windows Azure webjobs sdk for visual studio 2012 -

i have existing application developed in visual studio 2012 .net framework 4. , project hosted on cloud azure. want add windows azure webjob project in cannot find extension configure this. i find extension given below not working 2012 https://visualstudiogallery.msdn.microsoft.com/f4824551-2660-4afa-aba1-1fcc1673c3d0 is there way configure 2012. have windows azure 2.2 sdk installed. sorry, tooling available vs 2013. however, if want use webjobs sdk, can nuget package , create webjob have deploy manually.

forms - Rails - select_tag / chechbox tag issue - can't get array of IDs -

i've got list of products in form that's resource want submit. works without using label tag, want label tag working. <%= label_tag "product_ids[#{product.id}]" %> <%= check_box_tag "product_ids[#{product.id}]" %> <%= product.name %> <% end %> this produces following output: "product_ids"=>{"2"=>"1", "6"=>"1", "3"=>"1"} is possible array of ids , not hash? change <%= check_box_tag "product_ids[]", nil, nil, id: "product_ids[#{product.id}]" %> and params['product_ids[]'] try way?

c - Using "execv" or "execvp" to morph a program to isPrime? -

i have program called 'prime.c' below: #include "stdio.h" #include "stdlib.h" #include <unistd.h> int isprime(int number); void morph(char *number); int main(int argc, char *argv[]) { int i; int number; if (argc < 2) { printf("returning 2"); return(2); } else number = atoi(argv[1]); if (isprime(number)) { exit(1); } exit(0); } /* purpose: check if input number prime number input: number - number checked return: 0 - if number not prime number 1 - if number prime number */ int isprime(int number) { int i; for(i = 2; i*i < number; i++) { usleep(100); if (number % == 0) { printf("%d not prime number!",number); return(0); } } printf("%d prime number!",number); return(1); }

javascript - Why is waitFor() ignoring my return value? -

this code not working: casper.waitfor(function check(){ //wait new line appear in table , input box emptied console.log("in waitfor:"); console.log(casper.evaluate(function(){return $("table.packageslisting tr td:contains('some text')").length;}) ); console.log(casper.evaluate(function(){return $("table.packageslisting tr td:contains('some text')").length;}) == 1 ); return casper.evaluate(function(){return $("table.packageslisting tr td:contains('some text')").length;}) == 1 //&& //(casper.evaluate(function(){return $('input#addnewpackage').val();}) == "") ; },function then(){}, function ontimeout(){ this.capture("screenshots/"+label+".failed_timeout_waiting_for_package_add.png"); }); when run see is: in waitfor: 1 true in waitfor: 1 true ... in waitfor: 1 true in waitfor: 1 true and timeout! must mi

java - JavaFX Application keeps running even if i have an error in my main class static initializer -

keeps running: package app; import javafx.application.application; import javafx.stage.stage; public class test extends application { static { throwanexception(); } @override public void start(stage primarystage) throws exception { } public static void main(string[] args) { launch(args); } private static void throwanexception() { throw new runtimeexception(); } } stops: package app; import javafx.application.application; import javafx.stage.stage; public class test extends application { @override public void start(stage primarystage) throws exception { } public static void main(string[] args) { throwanexception(); launch(args); } private static void throwanexception() { throw new runtimeexception(); } } why? in first case program keeps running, exception. in second case program stops before calling javafx thread. static initializer should run befo

android - Cardview - white border around card -

i using cardview root of custom view writing. using v7 support library. xml looks this: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginright="6dp" card_view:cardelevation="0dp"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- other views --> </linearlayout> </android.support.v7.widget.cardview> my problem getting white border around card view. looks there indicate elevation thicker on right side. i've tried adjusting card

java - Change random operator or variable -

i have assignment in programming class. goes this, have make program takes input of user how many exercises wants do. solves simple calculations random numbers 1-10 , random operators. in end, should write how many correct , incorrect ones did get. should write elapsed time of task. did work, when assign random value operation int operation = (int)(math.random()*3)+1; or number , b int = (int)(math.random()*10); int b = (int)(math.random()*10); i same number , operator when choose second or third time task (because use loop). there way change same initialized variable or operator during program. example int a=(int)(math.random()*10) initialized in beginning example 3, , later when program loops again initialize different number, example 6. there others solutions problem? here whole code, now: import java.util.*; import javax.swing.joptionpane; public class randomchar { public static void main(string[] args) { char op= ' '; int operation =

Excel count instances of a value error -

Image
i need count amount of times value shows in b column , display in 3 seperate fields. came piece of code: =countif(b2:b6716,"0") =countif(b2:b6716,"1") =countif(b2:b6716,"2") but no matter how enter keeps telling me formula incorrect. tried removing " around 3 numbers aswell btw , in order test used words won't work. idea how can work? the error: try like: =countif(b1:b416; "=0") as criteria, should rather put string appended tested value forms condition, not particular number. way, can formulate more fancy criteria, like: =countif(b1:b416; ">100")

c++ - How to use miniupnpc with Boost.Asio UDP when binding a socket to a random port -

i'm astonished lack of documentation on miniupnp, believe there's lot of people using it, no documentation @ all, found piece of code in source of raknet guide me. now i'm having conceptual issue... i'm developing app connects server via udp (the server should accessible, server udp port specific 1 open, , can test using open port checker), server puts 2 or more clients talking each other (p2p), need circumvent nat in clients work. i have nat punch through working, , solves lots of cases. now, want add upnp functionality, attack nat issue too. i'm using miniupnpc, , handle connections boost.asio. struct upnpdev * devlist = 0; devlist = upnpdiscover(2000, 0, 0, 0, 0, 0); if (devlist) { std::cout << "\nlist of upnp devices found on network :\n"; struct upnpdev * device; for(device = devlist; device; device = device->pnext) { std::cout << "\ndesc: " << device->descurl << "\n st

selendroid - Is there any way to automate scanning of barcode from appium? -

i require app scan barcode automatically , have barcodes, have app required, how can make app read physical bar codes using automation in appium, in manual can scan code pointing out camera bar code. dont know how while executing test suite. got idea of placing mobile device on stand, tripod , placing barcode in front of it. problem can test 1 barcode. want run 100-200 barcodes ans see app performance not decrease, can 1 suggest ways? this interesting case. if want test app scanning bar codes through camera think instead of looking solution through appium have solution match manual process. you can click scan button using appium(i assume) - example can write script click on button every 10 seconds. challenge point camera next barcode first scan complete. possible solutions- believe bar codes can captured in file in pc. copy these bar code images in ppt or using other program these images can automatically displayed 1 one. put device in front of pc planning use tripod s

How to get the email of current logged in user from twitter in android -

i'm integrating twitter application using twitter 4j library. i'm trying extract email of logged in user. there way can take email address of user without having prompt them? i've checked here , doesn't quite explain how achieve i'm after. you can't email user easily, if check documentation need whitelisted twitter . if aren't, can't email, twitter4j doesn't provide method achieve that. and, possible duplicate: get user's email address twitter (android) email of twitter user in twitter4j

java - Does OpenXava framework support Web Services? -

i have openxava application , expose rest api allowing external users , other applications http post requests openxava entities, creating new resources in database. does know if openxava can generate web services entities? using openxava 5.2.1. i read documentation found nothing this. openxava not generates web services each entity automatically. however, openxava application regular java web application, can write web services application in usual way.

Printing the first value in an array instead of just the first letter? (Python) -

i have used python append data sqlite3 database array. have array, trying print appended data in format along lines of: print "team: " + new_array[0][0] + " score: " + new_array[0][1] + " overall: " + new_array[0][2] the code have okay this. however, trying create loop using counter print of data array in above format. the problem when try create loop , print first value in array, first letter of value printed. example: print new_array[0] ... print: team_6 team_3 team_5 team_1 team_2 team_4 ... and... print new_array[0][0] ... print: t t t t t t this have far: import sqlite3 new_array = [] conn = sqlite3.connect('league.db') c = conn.cursor() game = c.execute("select team,score,overall league order overall desc") items in game: new_array.append(items) print new_array[0][0] the code above print out 'team_6

c# - How to check a change in a Model Object fields without checking individual fields in MVC? -

i have big model public class somemodel { public int id { get; set; } .....a lot(24) of fields here..... } now on post actionresult edit(somemodel somemodel) want check if has been changed user respect original model values in database. using if else makes lot of messy code. there anyway check if altered user , if possible field altered user? i thinking using method one public class somemodel { //... public override bool equals(object obj) { var type = this.gettype(); bool sameobj = true; //for each public property 'somemodel' //[edited]type.getproperties().each(prop=>{ // sorry i'm using custom extension methode here //you should use instead type.getproperties().tolist().foreach(prop=>{ //dynamically checks they're equals if(!prop.getvalue(this,null).equals(prop.getvalue(obj,null))){ sameobj=false;

python - Sum slices of consecutive values in a NumPy array -

let's have numpy array a containing 10 values. example situation here, although repeat same array length 100. a = np.array([1,2,3,4,5,6,7,8,9,10]) i sum first 5 values followed second 5 values , on , store them in new empty list b . so b contain b = [15,40] . how go doing it? try list comprehension: b = [sum(a[current: current+5]) current in xrange(0, len(a), 5)] it takes slices of 5 @ time list, sums them , constructs list. works lists aren't multiple of 5 in length. ( xrange should range in python3+)

paypal - What is the payza equivalent php code for this snippet? -

below code use process payment in site. cart has 1 item. code paypal. want sell same item on payza. //process order paypal // prepare data $query = array(); $query['notify_url'] = 'http://mywebsite.com/ipn.php'; $query['cmd'] = '_cart'; $query['upload'] = '1'; $query['business'] = 'payment@mywebsite.com'; //main item $query['item_name_1'] = $item_name; $query['item_number_1'] = '1'; $query['amount_1'] = $item_price; $query['currency_code'] = "usd"; // prepare query string $query_string = http_build_query($query); header('location: https://paypal.com/cgi-bin/webscr?' . $query_string); <form method="post" action="https://secure.payza.com/checkou

jquery - fail in transmitting data in ajax -

i want make vote page. when click "", amount of vote plus meets "404 not found".(there no vote2.jsp in project because want refresh part of page.) vote.jsp <body> <div class="testspan" data-id="1"><span>vote a</span> num:<em>0</em></div> <div class="testspan" data-id="2"><span>vote b</span> num:<em>0</em></div> <div class="testspan" data-id="3"><span>vote c</span> num:<em>0</em></div> <div class="testspan" data-id="4"><span>vote d</span> num:<em>0</em></div> </body> ajax: $(".testspan").click(function(){ var xsid = $(this).attr("data-id"); $.post("/vote/vote2",{ xsid:xsid },function(data, textstatus){ var xsmap = data.xsmap; $(".testspan").each(func

java - Ant fails in try catch block -

in ant build have following code: <trycatch reference="exception_ref"> <try> <echo>start building delivery</echo> </try> <catch> <property name="exception" refid="exception_ref" /> <property name="message" value="error in trycatch block:${line.separator}${exception}" /> <echo message="${message}" /> <fail message="${message}" /> </catch> <finally> <echo>finally</echo> </finally> </trycatch> ant says: problem: failed create task or type trycatch cause: name undefined. action: check spelling. action: check custom tasks/types have been declared. action: check / declarations have taken place. what missing here? // edit: using ant in eclipse trycatch task provided ant-contrib third-party library. make sure download jar , have refere

c# - Dynamic IVR menu application in MVC using twilio API -

i trying develop application in mvc4 client can configure dynamic menu incoming calls user interface using twilio api. there opensource project exist or voice model dynamic ivr menu can idea , application flow gui design. in regard highly appreciated. twilio developer evangelist here. to knowledge there isn't .net project demonstrates how build ivr using twilio. however, there few tutorials showing how it, , because of uses twiml, should able generate using libraries, or making requests return such verbs when necessary. i stat off looking @ following: project: build simple ivr example in php, should able translate c# ivr: basics resource tells how ivr's work build ivr system twilio , django tutorial showing how build ivr using django with urls above should ale ivr , running in no time, means feel free reach out me if need help. i'm c# developer myself, able assist if stuck anything.

Undefined LatLng google map in AngularJs Controller -

i want retrieve longitude , latitude position of click mouse event, can't, gives me undefined. 1 can me please ? i'm using angularjs , found can google.maps.event.addlistener(map, 'click', function(event) { console.log(event.latlng); }); but can't in controller gives me error, or maybe don't know how use that!! here code : $scope.map = { center: { latitude: 36, longitude: -80 }, events: { "click": function (event) { console.log(event.latlng); } } } and tried gives me (nan,nan) $scope.map = { center: { latitude: 36, longitude: -80 }, events: { "click": function (event) { var pos = new google.maps.latlng(event.latlng, event.latlng); console.log("position: " + pos); }

visual studio - VisualSVN asking for TortoiseSVN -

i have team of 4 peoples, including me, going work on project. have installed visualsvn server on machine set svn server. have installed visualsvn client on machine , been integrated machine. here machine client , server. server other users , client me. earlier, had tortoise , visualsvn client. time working fine. have removed tortoisesvn, have installed visualsvn server. when "commit" changes, visualsvn says "tortisesvn not installed. ....." now using both visualsvn server , client, why should need tortoisesvn more? or wrong ..? i guess reason problem explained on https://www.visualsvn.com/visualsvn/download/tortoisesvn/ visualsvn uses tortoisesvn of dialogs. "add solution" wizard, "get solution" command , visual studio integration (status icons, transparent file operations etc.) not depend on tortoisesvn.

SQL count without wrapping query -

i have following hypothetical code , works getting number of rows of site select count(*) ( select site (select...) x left join foo.bars on foo.id = x.id group site ) is there other way count without using outer select? you can want count(distinct) : select count(distinct site) (select...) x left join foo.bars on foo.id = x.id; the 1 difference original version count null value of site . if important, query can modified take account.

javascript - Button listener to create incremented title -

i'm creating form website let users add step step tutorials. each time user clicks on 'add step' , new block image field , text field appears. i'm beginning jquery , wanted have title displayed before every new block appearing after user's click 'step 1' ... 'step n' i tried adding html field block , filling (263 id of 'add step' button , 323 of htlm field added): $x = 0 $([263]).click(function () { $x ++ ; $("[323]").val("step $x"); } but doesn't work ... me please ? thanks :) use id selector jquery #... , missing close ); click function. , .text() used set h1 title: var x = 0 $("#323").text("step " + x); $("#263").click(function() { x++ ; $("#323").text("step " + x); }); and don't use $x looks php world :) you can fiddle around code here http://jsfiddle.net/uh8m2wax/ you can place code @ end of page prior body tag this:

stl - passing values to Pair in c++ -

i have pair type of string , string &, may pass values pair shown below typedef std::pair<std::string, std::string&> namednode; voi main(){ std::string name = "name"; std::string * value = new std::string("value") ; namednode(name,*value);} when pass values pair shown above got following errors error c2529: '_val2' : reference reference illegal c:\program files (x86)\microsoft visual studio 9.0\vc\include\utility error c2665: 'std::pair<_ty1,_ty2>::pair' : none of 3 overloads convert argument types d:\jzon\sample.cpp and below warning warning 1 warning c4181: qualifier applied reference type; ignored c:\program files (x86)\microsoft visual studio 9.0\vc\include\utility i'm using c++98, microsoft visual studio 2008, os-windows xp thanks.., no it's *value . the standard main in c++ int main() when no interest in command line paramenters , int main(int argc, char* argv[]) or int main(i

java - contains() method in List not working as expected -

the api of contains() method says "returns true if list contains specified element. more formally, returns true if , if list contains @ least 1 element e such (o==null ? e==null : o.equals(e)). " i overrode equals() method in class contains() still returns me false when check my code class animal implements comparable<animal>{ int legs; animal(int legs){this.legs=legs;} public int compareto(animal otheranimal){ return this.legs-otheranimal.legs; } public string tostring(){return this.getclass().getname();} public boolean equals(animal otheranimal){ return (this.legs==otheranimal.legs) && (this.getclass().getname().equals(otheranimal.getclass().getname())); } public int hashcode(){ byte[] byteval = this.getclass().getname().getbytes(); int sum=0; for(int i=0, n=byteval.length; i<n ; i++) sum+=byteval[i]; sum+=this.legs; return s

magento set drop down as readonly not working -

i need set drop down readonly. put as; <select readonly="readonly" name="name" > <option>1</option> <option>2</option> <select> but not working. since readonly, can change drop down value. please help.thank you. the select tag doesn't have readonly attribute. have disabled . the problem disabled form inputs don't included in post / data. to around this, add hidden input same name , value.

unable to take screenshot of mouseover in selenium -

Image
i trying take screenshot of sub menu happens on hovering in selenium using takesscreenshot . not working. screenshot taken sub menu not present in image. have tried using implicit wait after hover, nothing worked. please suggest method capture screenshot of sub menu. contactus.hoverhm(); screenshot = ((takesscreenshot) pagefactorybase.getsharedwebdriver()).getscreenshotas(outputtype.bytes); scenario.embed(screenshot, "image/png"); this did trick me. pretty sure work you. _driver = new firefoxdriver(); _driver.navigate().gotourl("http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_mouseover_mouseout"); _driver.switchto().frame(_driver.findelement(by.id("iframeresult"))); actions builder = new actions(_driver); builder.movetoelement(_driver.findelement(by.tagname("p"))).build().perform(); var screenshot = ((itakesscreenshot)_driver).getscreenshot

kendo ui mobile position element at bottom -

i'm trying position element @ bottom of mobile page using kendo ui mobile. have tabstrip @ bottom, , don't want footer styling, unfortunately data-role="footer" won't cut it. i'vetried setting style="bottom:-1em;" doesn't work, places div before -1em. for bottom style work, should either use position: fixed or absolute. position fixed should position according viewport, regardless of element's container. position: fixed rather buggy on mobile platforms. position: absolute on other hand position element according positioned container, in order use it, can place element in footer. absolute position remove element page flow, won't affect positioning of tabstrip have there. footer doesn't have overflow: hidden, element can positioned outside of , on content if want.

Optimize nutch performance on hadoop cluster -

i'm trying optimize nutch performance crawling sites. test performance on small hadoop cluster, 2 nodes 32gb ram, cpu intel xeon e3 1245v2 4c/8t. config nutch http://pastebin.com/bbrhpfuq so, problem: fetching jobs works not optimal. reduce task has 4k pages fetching, 1kk pages. example see screenshot https://docs.google.com/file/d/0b98dgnxoqkmvt1doovvpuu1pnxm/edit reduce task finished in 10 minutes, 1 task work 11 hours , still continue working, it's bottle neck when have 24 reduce task, works one. may can give usefull advices or links can read problem. it problem in nutch, takes 50 000 000 1 site , 500 000 other. when creating queue host see 1 extremely big queue , other small.

algorithm - Generating numbers which follow Normal Distribution in Java -

i want generate numbers(randomly) such numbers follow normal distribution of given mean , variance. how can achieve this? it better if can give in context of java. 1 might in these answers help: not precise. generate random numbers following normal distribution in c/c++ shamelessly googled , taken from: http://www.javapractices.com/topic/topicaction.do?id=62 the 'magic' happend inside random.nextgaussian() import java.util.random; /** generate pseudo-random floating point values, approximately gaussian (normal) distribution. many physical measurements have approximately gaussian distribution; provides way of simulating such values. */ public final class randomgaussian { public static void main(string... aargs){ randomgaussian gaussian = new randomgaussian(); double mean = 100.0f; double variance = 5.0f; (int idx = 1; idx <= 10; ++idx){ log("generated : " + gaussian.getgaussian(mean, variance)); } } pri

How to get php -r to output on OSX command line -

i trying run like php -r 'echo "test"' on mac osx command line. throws no error, in fact nothing happens @ all. how can output "test" on command line? thanks answers you need semi-colon mark end of command, i.e. php -r 'echo "test";' (or php -r 'echo "test\n";' to move new line.)

java - Problems Resteasy 3.09 CorsFilter -

i tried use new corsfilter available in resteasy 3.0.9. found example @ bottom of page: ajax request jax-rs/resteasy implementing cors if define filter in method getsingletons() (of application subclass) , resources don't scanned anymore. means no resources found , following error occurs: javax.ws.rs.notfoundexception: not find resource full path error occures on following page found description: javax.ws.rs.notfoundexception: not find resource full path error occures but basically, deployment option scan annotations of @path, @provider, etc application. reason jax-rs first classes , object in overridden getclasses() , getsingletons(), respectively. if return empty sets, tell jax-rs scanning (per spec). so jax-rs doesn't scanning if overwrite getsingletons() method? there way configure corsfilter , enable resource scanning`? "is there way configure corsfilter , enable resource scanning?" one way keep scanning implement javax.w

Extract and rewrite data from XML file in PHP -

i have xml data in file want extract , write user's input in xml format. want extract , change data highlighted in bold. kindly find below xml data : <threadgroup guiclass="threadgroupgui" testclass="threadgroup" testname="mp search za - auth user" enabled="true"> <elementprop name="threadgroup.main_controller" elementtype="loopcontroller" guiclass="loopcontrolpanel" testclass="loopcontroller" testname="loop controller" enabled="true"> <boolprop name="loopcontroller.continue_forever">false</boolprop> <intprop name="loopcontroller.loops">-1</intprop> </elementprop> <stringprop name="threadgroup.num_threads">**1**</stringprop> <stringprop name="threadgroup.ramp_time">**2**</stringprop> <longprop name="threadgroup.start_time">

c - If sigwait() blocks, when is the accepted signal actually "selected"? -

there 2 real-time threads. first 1 has low priority , waiting possible signals in sigwait() (so signals blocked , sigmask passed function has signals enabled). second 1 has high priority , sends 2 signals first (low priority) thread - first sends sigrtmax , sigrtmin . posix spec sigwait() ( http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwait.html ) says this: if no signal in set pending @ time of call, thread shall suspended until 1 or more becomes pending. [...] should of multiple pending signals in range sigrtmin sigrtmax selected, shall lowest numbered one. the sequence of events in real-time operating system that: (h)...............signal(sigrtmax)===signal(sigrtmin)===... (l)===sigwait().........................................=== ^ ^ ^ ^ 1 2 3 4 (h) - high priority thread (l) - low priority thread . - thread not running = - t

javascript - Web Audio API filter not working in Safari -

i in process of developing html5 canvas interactive piece uses createjs , web audio api. i've managed audio working in chrome/firefox/safari despite deprecation of webkitaudiocontext chrome , ff not safari. however, filters reason not working in safari, sound still plays. filters work in chrome/ff. i have filters set this: var sound = new audio(); sound.src = './sounds/sound.mp3'; sound.autoplay = false; sound.loop = true; soundsource = context.createmediaelementsource(sound); var soundfilter = context.createbiquadfilter(); soundfilter.type = "lowpass"; soundfilter.frequency.value = 500; soundsource.connect(soundfilter); soundfilter.connect(context.destination); am unknowingly using deprecated term or something? live project can found here . cheers. update : has been recognised genuine bug webkit team, , patched. full details here apparently safari doesn't implement createmediaelementsource correctly . instead of redirecting sound through

jquery - Multiple Ajax Async call -

i have list of lib name name want fetch author name. made each loop on library name , make async call. want return author name library name once call end. while try async call return call before call successes. have try return callback in success call return once first request completed. have try sync call block user interface. best method that. code function fetchlibauthorid(libcollection, callback) { $.each(libcollection, function (key, value) { $.ajax({ url: value.metadatauri + '?$select=schemaxml', type: "get", headers: { "accept": "application/json;odata=verbose" }, success: function (data) { var listproperties = schemaxml2json(data.d.schemaxml); libcollection[key].authorid = listproperties.author; libcollection[key].rootfolder = listproperties.rootfolder; }, error: function (data2) { alert('error'); } }); }); return

I can't see apk on android phone -

the error show me, can't use apk , can't display apk on phone screen. [2015-04-01 16:53:46 - bus] ------------------------------ [2015-04-01 16:53:46 - bus] android launch! [2015-04-01 16:53:46 - bus] adb running normally. [2015-04-01 16:53:46 - bus] no launcher activity found! [2015-04-01 16:53:46 - bus] launch sync application package on device! [2015-04-01 16:53:46 - bus] performing sync [2015-04-01 16:53:49 - bus] application deployed. no need reinstall. [2015-04-01 16:53:49 - bus] \bus\bin\bus.apk installed on device [2015-04-01 16:53:49 - bus] done! you need add <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> for example: <activity android:name="main.startactivity" android:label="@string/app_name" > &

ios - Reload data of UITableView in background/foreground at specific time -

in application, have uitableviewcontroller . need reload data of tableview daily morning @ 12:01am whether application in background or foreground. think using local notification possible, don't know how do. please me. thanks. you need use remote notifications wake app @ scheduled time. can use: - (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler this called when application receives remote notification. put table view reloading code in here. you can use web service such parse.com or urbanairship schedule notification sent @ specific time sources: apple developer reference notifications guide

stl - C++.How output elements from std::set in format "(element, element, element)" without last ", "? -

this question has answer here: printing lists commas c++ 23 answers when using std::list, have method "back()": for ( = list->begin(); != list.back(); it++ ) { cout << it.getname() << ", "; } cout << it.getname() << endl; output: (element, element, element) std::set has no member back(), , can't output last element without ", ": output: (element, element, element, ) this enough uses: for (auto = list.begin(); != list.end(); ++it) { if (it != list.begin()) cout << ", "; cout << it->getname(); } if want ( ) around output, add cout s either side of loop. if you're mad-keen keep conditional out of loop: if (!list.empty()) { auto = list.begin(); cout << it->getname(); while (++it != list.end()) cout <<

arrays - php mysqli_query function seems to run twice -

this custom function site need show different url's inside iframe. want show each url once user first creating array of available urls, array of seen urls , compare 2 create new array urls shown. need echo first element of array iframe. the problem seems lie within foreach function execute entry database $entry = "insert views values ('', '$currentusername', '$urltoshow')"; i tried many different approaches, no matter 2 urls $urlstoshow array added database , 1 of them gets echoed inside iframe. result every other site gets skipped altogether , user never sees them. i have print_r'd $urlstoshow make sure array , did same make sure $urltoshow not array. i'm not sure if php problem more... here code: function get_urls() { require 'config.php'; global $con; global $currentusername; $con = mysqli_connect($hostname, $dbusername, $dbpassword, $dbname); $query = "select site_url sites site_url n