Posts

Showing posts from March, 2014

visual studio 2010 - MSVS : C++ : Allegro 5 template : Agui GUI API : How to setup includes? -

i use allegro 5 library work graphics in c++ in microsoft visual studio. found great allegro 5 template called "agui gui api" have struggled understand how set up. extreme beginner when comes setting coding environment. following me lot. recommendation keep agui files , if copy them each new project? how include them in msvs compile , run agui_example.cpp? files: https://code.google.com/p/agui/ i found looking here: windows, visual studio 2010 , allegro 5 - allegro wiki

windows phone 8 - Best approach for playing a single tone audio file? -

can tell me best approach playing single-tone, audio (.mp3) files in windows phone 8 app? think of piano app, each key represent button, , each button play different tone. i'm looking efficient way go - i've got 8 different buttons need play different tone when tapped. i tried using mediaelement : mediaelement me; public mainpage() { initializecomponent(); me = new mediaelement(); me.autoplay = false; me.source = new uri("/sounds/sound1.mp3", urikind.relative); btnplay.click += btnplay_click; } private void btnplay_click(object sender, eventargs e) { me.play(); } but nothing happens, either in emulator or on device (testing w/ lumia 822). doing wrong here? seems should pretty simple. or using mediaelement best thing use scenario? would fall under background audio category? i've read through example seems overkill want do. i've read using xna's soundeffect job, i'd have convert .mp3 files .wav (which isn&

asp.net mvc - Why class attribute not work in WebAPI? -

i used default asp.net mvc4 web application template , visual studio create initializesimplemembershipattribute in filters directory , create account controller this: [authorize] [initializesimplemembership] public class accountcontroller : controller { /* default actions login, logoff, register, ...*/ } and try make accountcontroller webapi, code is: [authorize] [initializesimplemembership] public class apiaccountcontroller : apicontroller { [system.web.http.acceptverbs("get", "post")] [system.web.http.httpget] [system.web.http.httppost] [system.web.http.allowanonymous] [system.web.mvc.validateantiforgerytoken] public string login(string username, string password, bool rememberme) { if (websecurity.login(username, password, persistcookie: rememberme)) { return "ok"; } return "failed"; } } now, when call api, break in line: if (websecurity.login(username,

Bootstrap starter template collapsed menu doesn't highlight properly -

just displaying url http://twitter.github.io/bootstrap/examples/starter-template.html# correctly don't understand (ok i'm starting bootstrap) when reduce browser window size, menu button, menu displayed home option highlited correctly when hovering on it. put js @ end of body , jquery before bootstrap.js. same thing firefox or chrome , internet explorer 10 demo not responsive menu button doesn't appear nav stay same. regarding point links don't change on hover screens < 980px wide, i'm not sure if behaviour intentional or not, it's coming line 1028 of bootstrap-responsive.css if want link colors change on hover, edit styling below force color #fff: .navbar-inverse .nav-collapse .nav > li > a:hover, .navbar-inverse .nav-collapse .nav > li > a:focus, .navbar-inverse .nav-collapse .dropdown-menu a:hover, .navbar-inverse .nav-collapse .dropdown-menu a:focus { background-color: #111; color: #fff; } the color home link special ca

php - Background is turning out black -

i have done possibly try fix this. i've spent on hour researching , trying code, nothing has helped. this code following. take 2 completely-white images , re-color them ( while keeping transparency ) merge 2 images together outputs images (but with black background!!) can identify , patch part that's causing black background? see following url example of script. http://labs.bluefiremedia.net/metro-machine/gd/download-png.php?size=128&padding=29&icon=icons/application/add-new.png&bgshape=circlebg.png&bgcolorr=255&bgcolorg=0&bgcolorb=0&iconcolorr=255&iconcolorg=255&iconcolorb=255 $final_image = imagecreatetruecolor($dimensions, $dimensions); imagesavealpha($final_image, true); if($bgshape != '') { list($originalwidth, $originalheight) = getimagesize('../images/' . $bgshape); $background = imagecreatefrompng('../images/' . $bgshape); imagefilter($background, img_filter_brightness, -255); imagefilter

graph - Algorithms: Esau-Williams algorithm -

i ask there sittuations esau-williams algorithm may useful? know used solve cmst problem, can't find sittuation cmst problem may appear. according wikipedia , "cmst problem important in network design: when many terminal computers have connected central hub, star configuration not minimum cost design. finding cmst organizes terminals subnetworks can lower cost of implementing network."

xmlhttprequest - Refused to get unsafe header "Content-Range" -

for reason cannot access response header of "content-range" anymore... therefore it's impossible determine file size of resource using xhr. error refused unsafe header "content-range" on chrome in line: var cr = this.getresponseheader('content-range'); here's cors config: <?xml version="1.0" ?> <corsconfig> <cors> <origins> <origin>*</origin> </origins> <methods> <method>get</method> <method>head</method> <method>delete</method> </methods> <responseheaders> <responseheader>x-goog-meta-foo1</responseheader> <responseheader>origin</responseheader> <responseheader>range</responseheader> <responseheader>content-range</responseheader> <responseheader>content-length</responseheader> </

asp.net - Read excel sheet cell in C# -

Image
i try read .xls flie using c#. this code oledbcommand command = new oledbcommand("select [id], [name], [email] [sheet$]", connection); oledbdataadapter objadapter = new oledbdataadapter(); objadapter .selectcommand = command; dataset objdataset = new dataset(); objadapter .fill(objdataset1); dataview dv = objdataset .tables[0].defaultview; (int = 0; < dv.count; i++) { if (dv[i][0] != dbnull.value ) { } } but in excel sheet cell has green color mark not read. it null. how can read cells? thank you. based on past experience, excel making best guess each column's data type, , gets wrong. doesn't match presumed data type returned null. @ below, particularly regards imex setting. http://www.connectionstrings.com/excel#microsoft-jet-ole-db-4-0

jquery - Use variables outside the function -

below getting long/lat address google api. variables longitude , latitube need use gmap. creating map_canvas. how done use these variables in next function? (where long/lat written per numbers) jquery: var geocoder = new google.maps.geocoder(); var address = markerinformation = $('#googlemaplocation').val(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { latitude = results[0].geometry.location.lat(); longitude = results[0].geometry.location.lng(); } }); markerinformation = $('#googlemapinformation').val(); $(function() { demo.add(function() { $('#map_canvas').gmap({'center': '57.7973333,12.0502107', 'zoom': 10, 'disabledefaultui':true, 'callback': function() { var self = this; self.addmarker({'position': thi

ios - How can I search for locations in a certain radius? -

very surprised has been difficult search. hunt showed me use clgeocoder displaying information in user friendly format. i'm building location based app, , have functionality save locations (to server) , list them in table view. of little use when cannot filter , arrange locations relevant area. should heavy lifting of setting location radius in device, or in php? my current idea solution send json string of coordinates php script looks through mysql database every entry has location field less x away user's location (by crude 'where x<34.23049823 , x>34.44789874 , y<...) type of thing. don't think easiest or quickest way implement nearby location search functionality. of course can in ios. // given nsarray *locations array of cllocation* wish filter // , given radius... cllocationdistance radius = ksomeradius; // , given target want test against... cllocation* target = [[cllocation alloc] initwithlatitude:somelat longitude:somelon]; ns

java - Check if Android Media Player can play a file -

in android, there way check if given file legitimate file media player? current method of testing if file playable or not in media player. public boolean isplayable(file file){ try { uri uri = uri.fromfile(file); player.setaudiostreamtype(audiomanager.stream_music); player.setdatasource(this, uri); player.reset(); return true; } catch (exception e){ toast.maketext(this, "invalid file: " + file.getname(), toast.length_short).show(); return false; } } i'm using exception test, if throws exception , shouldn't play file. me, doesn't seem clean though seems job fine. there better way should looking @ problem? want know if file going throw exception before try plug media player.

pycparser - Getting source line number from AST -

i'm looking parsing c-file pycparser , i'm trying source line number ast generated pycparser. possible? it possible "coord" object. have @ coord class in plyparser.py https://bitbucket.org/eliben/pycparser/src/b169b693a194/pycparser/plyparser.py?at=default

asp.net - IIS Url rewrite username -

how can rewrite url in iis mysite.com/profile.aspx?user=foo to mysite.com/foo this rewrite condition i've tried in .htaccess rewriterule /foo/(.*) /bar?arg=p1\%3d$1 [r,ne] but how can in iis url rewrite? quite simply: <rule name="profile rewrite" stopprocessing="true"> <match url="^([^/]+)/?$" /> <conditions> <add input="{request_filename}" matchtype="isfile" negate="true" /> <add input="{request_filename}" matchtype="isdirectory" negate="true" /> </conditions> <action type="rewrite" url="profile.aspx?user={r:1}" /> </rule> note apache rewrite rule won't expect @ all. note can generate url rewrite visual configure tool within iis manager.

c# using statement and StreamWriter -

i using streamwriter write things notepad. , discover if not using statement , instance streamwriter alone. method unable run. know reason? static void main(string[] args) { //streamwriter c = new streamwriter(@"c:\users\rxxx\desktop\important.txt", true); using (streamwriter c = new streamwriter(@"c:\users\xxx\desktop\important.txt", true)) { c.writeline("hello"); } this can run. if run remarked part instead. notepad shows nothing. anybody knows reason? because when use object in using practice, calls dispose method , in case of streamwriter call fush on object causes data written in file. write code this: var c = new streamwriter(@"c:\test\important.txt", true); c.autoflush = true; c.writeline("hello"); c.dispose();

java - data will not populate listview -

i'm having issues populating listview. thought had modifed xml , adapters accordingly apparently not. when activity loaded dialog pops stating it's loading app force closes. if remove 3 lines of coding stating listview.settext(name) loads items default text in xml file. code looks this: public class displayserviceactivity extends listactivity { private listview listofservices; //jsonarrays? jsonarray directory; //json node names private static string tag_id = "id"; private static string tag_name= "name"; private static string tag_directory = "categories"; private final static string url= "api link here"; jsonobject json; jsonparser jparser = new jsonparser(); arraylist<hashmap<string, string>> directorylist; @suppresslint("newapi") protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.service); direct

java - How to replace an escape char? -

i'm trying sanitize/standardize user input file directories. windows \ , *nux/*nix / . in java \ must escaped \\ otherwise compile error. how can read \ user input , replace / ? private string escapedirs(string raw) { return raw.replace("\\", "/"); } this not work... presumably because it's read in \ not \\ . can't raw.replace("\", "/"); ... sample user input: c:\user\someuser\somedir if building solution windows , unix both 1 of issues developer need take care there 2 approaches handle escape characters windows seperately using \ , paths unix seperately use / in paths windows , same used in unix , windows example in windows c:/temp works same c:\temp in unix /tmp/ hope helps thanks abhi

java - Print JLabel with JTable in desktop application -

how print jlabel jtable in java standalone application? i have created gui in added label , 1 jable . want print gui. used table api print table. if print component content of table not visible. i using netbeans ide 7.2 here code have used: import java.awt.graphics; import java.awt.graphics2d; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.print.pageformat; import java.awt.print.printable; import java.awt.print.printerexception; import java.text.messageformat; import java.util.logging.level; import java.util.logging.logger; import javax.swing.joptionpane; import javax.swing.jtable; public class frm1 extends javax.swing.jinternalframe implements printable,actionlistener{ /** * creates new form frm1 */ public frm1() { initcomponents(); jbutton1.addactionlistener(this); } /** * method called within constructor initialize form. * warning: not modify code. content of method * regenerated form editor. */ @suppresswarnings(&

html - How do I populate a table in Javascript by clicking a button using the onClick() function? -

using javascript, want populate numbers in soduku.setstring(); table once user clicks button "easy". how can achieve using onclick() function? function initialize() { var col, row; (row = 0; row <=8; row++) { (col=0; col <= 8; col++) { var cell = document.getelementbyid('cell_' + col + '_' + row); if (!parseint(cell.innerhtml)) { // cell empty cell.onclick = selectcell; cell.classname = 'tofill'; } } } document.onkeypress = keypress; } function easygame(){ var sudoku.setstring("240057360000008009378000200060041702080000005000005010130000000050003026000812000"); loadpuzzle(sudoku); updateui(); } function updateui(){ initialize(); } <input type="button" value="easy" onclick="easygame()"/> <table align=center id="sudoku" cellspacing=0> <tr> <td id="cell_0_0"></td> <td id="cell_1_0"></td> <td id="cell_2_0

c# - Need to refresh drop down after we have inserted newly values in database -

i have page using 2 user controls. 1 control reservation control , other channel partners control. on reservation control have drop down has channel partners. when user has new channel partner clicks addnewchannel link , channel partner comes pop , after user inserts new channel partner database. problem whan data inserted database want drop down on reservation refreshed , should contain new channel partner. tried this: updatepanel upnl = (updatepanel)page.findcontrol("updatepanel1"); if (upnl != null) upnl.update(); my drop down on reservation control in in update panel. didnt work. try appreciated. assumption: channel partners user control contains popup add new partners. popup has save button (asp.net serverside control) server side click handler commits data database. user control includes additional update panel async postback trigger when user saves new partner form doesn't postback, instead makes async postback so use events allow user contr

c# - Convert sql ce tables to .xls or .xlsx format -

i have c# windows application makes use of database in sql compact edition 3.5 data manipulation. convert each table in database excel file. realise read cell cell , export excel, however, have lot of tables (upwards of 100) , take long time. there method convert tables in sql ce database file excel spreadsheets in quicker manner. my users wanted data in excel because wanted access raw, unmanipulated data reference purpose. also, quite comfortable excel. is there simple technique accomplish this? use closedxml it's open source using system.data; class program { static void main(string[] args) { datatable table = new datatable("test"); table.columns.add(); table.columns.add(); table.rows.add("1", "2"); table.rows.add("3", "4"); closedxml.excel.xlworkbook workbook = new closedxml.excel.xlworkbook(); workbook.worksheets.add(table); workbook.sav

How do I stop javascript php gallery at last or first image? -

i have simple jquery , javascript image gallery uses php gather images , put them in li tags. gallery works (almost) , go left , right through images, cannot them stop going right @ end , left on first, keep scrolling through nothing. .js code looks this: var currentimage = 1; var numimages = 0; $(document).ready( function(){ $('.rightbtn').click(function(){ moveleft(); }); $('.leftbtn').click(function(){ moveright(); }); $('.gallery-li').each(function(){ numimages++; }); }); function moveleft() { if ( currentimage < numimages ) { $('.gallery-ul').animate( { 'marginleft' : '-=600px' } , 500, 'swing' ); $currentimage++; } if ( currentimage > numimages ) { $('.rightbtn').css('display' , 'none'); } } function moveright() { if ( currentimage = 1 ) { $('.gallery-ul').animate( { 'marginleft' : '+=600px&#

code coverage - how to run JSCover on windows -

i've spent quite time try using jscover allows monitor code coverage of javascript code. compelling may sound, not seem straight forward deal. here manual have , can sworn tried following instructions given here still cannot run basic example. http://tntim96.github.io/jscover/manual/manual.xml#gettingstarted i unable run "example-server.sh"...i pretty sure might missing something...but unable figure out...my question if here have tried running jscover on windows? if yes, can me in doing same... thanks in advance... for windows, try running example-server.bat. alternatively, can try running command line using: java -jar target/dist/jscover-all.jar -ws --branch --document-root=doc/example --report-dir=target make sure have java installed, , running in jscover directory root. if still error, can post details? also, quick response, try posting question at: https://github.com/tntim96/jscover/issues

I want to connect a php class library one server to another -

i creating php class library , want place on own server , related application code placed on server. need synchronize them ie class library accessed application(s) on other server. how provide solution other application(s) access library. there several ways access library, can't access other local libraries or classes. way use web services. a solution use soap. php provides api soap, enables create soap server , client easily. you create soap web server @ library end (on server library placed), , expose functions web service need access. solution , easy use. can find soap in php article here http://www.codewalkers.com/c/a/miscellaneous/using-soap-with-php/ and read these https://stackoverflow.com/questions/8657980/how-to-make-web-service-in-php php web service example and http://www.vankouteren.eu/blog/2009/03/simple-php-soap-example/ also way use xml , json. please read article. http://davidwalsh.name/web-service-php-mysql-xml-json please m

php - Extract Video URL or ID From a YouTube Playlist Using YouTube API -

i using following php script grab title , description each of youtube videos in playlist, have not been able figure out how grab youtube id or url videos. query need? <?php $cont = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/playlists/atwambkrzsrgvsvxlcw74lu7jb31954x/?v=2&alt=json&feature=plcp')); ?> <?php $feed = $cont->feed->entry; ?> <?php if(count($feed)): foreach($feed $item): // youtube start ?> <?php echo $item->title->{'$t'} ?> <br /> <?php echo $item->{'media$group'}->{'media$description'}->{'$t'} ?> <?php endforeach; endif; // youtube end ?> <?php $cont = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/playlists/atwambkrzsrgvsvxlcw74lu7jb31954x/?v=2&alt=json&feature=plcp')); ?> <?php $feed = $cont->feed->entry; ?> <?php if(count($feed)): foreach($feed $item): // youtub

jquery - Binding data to collapsible set in phonegap -

i have collapsible set trying append query result listview. unable bind result listview. this trying do function querydb(tx) { tx.executesql('select * folder', [], querysuccess, errorcb); } function listdata(tx,results){ list= ("<ul data-role='listview' data-inset='false' id='mylist' />"); count = results.rows.length; $.each(results.rows,function(index){ var row = results.rows.item(index); var li = '<li><a href="#">'+row['date']+'</a></li>'; list = $(list).append(li); }); } function querysuccess(tx, results) { $.each(results.rows,function(index){ var row = results.rows.item(index); tx.executesql('select date allignment name="'+row[name]+'"', [], listdata, errorcb); var div = '<div data-role="collapsible" data-inset="false" data-iconpos=&q

How can I build glib at c++ - compile error when build .cpp -

all when build cpp using g++ , glib, meet compile error. c , gcc version ok. i'm building @ ubuntu 10.xx. built @ windows - c++. how can build glib @ c++? you. #include <glib.h> int main() { g_printf("test"); return 0; } jongwon_kwak@kwak-com:~/worksapce_cxx/testglib/src$ g++ -c -i/usr/include/glib-2.0 -i/usr/lib/i386-linux-gnu/glib-2.0/include testglib.cpp testglib.cpp: in function ‘int main()’: testglib.cpp:12:17: error: ‘g_printf’ not declared in scope you missing #include <glib/gprintf.h>

livescript - How to ignore return result -

for example child.stdout.on \data (buffer) -> result.stdout += buffer --> child.stdout.on('data', function(buffer){ return result.stdout += buffer; }); and need without return. in f# can add |> ignore how can handle in livescript? you can prepend ! definition of function: !(buffer) -> result.stdout += buffer alternatively, return void child.stdout.on \data (buffer) -> result.stdout += buffer void in javascript, when return undefined (void), same not returning anything.

javascript - form validation for at least on select-option is selected -

my form layout similar below: <form action='' method="post" id='myform'> <select name='select1'> <option value=''>select option</select> <option value='a'> </option> <option value='b'> b </option> <option value='c'> c </option> </select> <select name='select2'> <option value=''>select option</select> <option value='e'> e </option> <option value='f'> f </option> <option value='g'> g </option> </select> <select name='select3'> <option value=''>select option</select> <option value='h'> h </option> <option value='i'> </option> <option value='j'> j </option> </sel

Pros and cons of using AngularJS + jQuery Mobile in one project -

we're start project using mentioned libraries. have used jqm in project, coupled backbone. we're thinking using angularjs jqm. think it's idea? , if not, why? to elaborate, question whether advisable/recommended/easy/beneficial use these libraries together, or maybe there should prevent using them both in 1 project. don't want spend half of project's time on making them work on principle. angularjs , jqm different things. angularjs mvc + lot more. jqm on other hand direct ui manipulation (lower level angular). news angularjs flexible , let work other javascript framework including jqm. recommended way of using them use adapter mentioned above or create own reusable directives add "jqm nature" views. e.g. can create directive convert standard ul fancier jqm list. thing doing in directives , not within view ui code separated in separate modules , not intermingled business logic.

user interface - When does the touch keyboard popup? -

i'm working on non-touch device (regular pc...) keyboard. i've written windows 8 app, includes textbox. i want launch touch keyboard, when user uses device without keyboard (=tablet/phone). how can test it? i.e. when use visual studio simulator windows 8 , choose "taps" gesture, virtual touch keyboard still won't popup. there specific moment windows using keyboard automatically? i'd test touch keyboard check inputscope (i.e. inputscope="number") , 'look of app', when keyboard pops up. if needed, textbox looks this: <textbox inputscope="number"/> edit: keyboard pops (i don't know why...). i've started simulator , used "taps" gesture , keyboard didn't pop up. after restarting simulator ~5 times, pops now, inputscope not number... visual studio 2012 comes simulator can run windows 8 app in. on right of that, may notice buttons near top, 1 that's pointer , that's finger. if use

c# - SqlCeUpdatableRecord setDatetime convert '2079' -

in sql database have smalldatetime record '1.1.2079'. want insert record sql compact datetime record. i'm using sqlceupdatablerecord , setdatetime rec.setdatetime(i, convert.todatetime(sqldatareader[columnname].tostring())); but in compact database record '1.1.1979'. don't why. can please tell me how '1.1.2079' in compact version also. found solution: rec.setdatetime(i, convert.todatetime(sqldatareader[columnname])); there no need convert .tostring() value sqldatareader .

shell - using wget to get excel file -

i'm sorry not speak english well. want use wget excel file link : http://app/sip/rkn/export.php?p1=1&p2=613&p3=01&p4=31&p5=01&p6=2013 but i'm getting error message : 'p2' not recognized internal or external command, operable program or batch file. 'p3' not recognized internal or external command, operable program or batch file. 'p4' not recognized internal or external command, operable program or batch file. 'p5' not recognized internal or external command, operable program or batch file. 'p6' not recognized internal or external command, operable program or batch file. what can solve issue? in advance! the problem & character interpreted shell, has special meaning (see here ). try following commands in shell understand does: $ sleep 2 && echo "2 seconds have passed" $ sleep 2 && echo "2 seconds have passed" & simplified, syntax runs specified co

performance - Perfomance of the PAGE_WRITECOPY windows internal memory -

i need implement undo-redo feature in application, reads project file , makes sequence of separate transactions changing project's content. project can hundreds mb large. my idea implement undo-redo on basis of copy-on-write (page_writecopy) memory mechanism. assume after end of transaction application can access both changed , unchanged pages, compare them, identify changed records, store original record states in dedicated undo stack, free created non-changed pages , restore write-on-copy protection of changed pages. have 2 questions: how , can found addresses of original (non-changed) pages. the awaited performance of such implementation?. middle size of project's records cira 100 bytes. if transaction changes 3000 records may involve change of 100 or more 4k physical pages. write-on-copy memory performant enough support routineous change of hundreds physical pages on each step?

regex - How to rewrite url while keeping additional parameters in .htaccess file? -

i have standard htaccess catches , puts 1 url parameter later processed in code... rewriterule ^config/ - [f] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !=/favicon.ico rewriterule ^(.*)$ index.php?q=$1 [l,qsa] i use "pretty" url params /some/route/param1/value1/param2/value2 but need ability add "regular" url params like /some/route/param1/value1?param2=value2&param3=value3 etc i tried adding rewriterule ^(.*)\?(.*)$ index.php?q=$1&p=$2 [l,qsa] before existing rule, won't work (and suspect work 1 parameter). try this: rewriterule ^([^?]+)\?(.*)$ index.php?q=$1&p=$2 [l,qsa]

java - Monitoring BufferedInputStream download progress -

i'm trying download file using asynctask on android. want display progressdialog should have progress bar show status of download. i'm using onprogressupdate() function , implemented call publishprogress() in doinbackground() function. however, progress dialog pops after downloading file. code: protected long doinbackground(url...urls) { (int = 0; < urls.length; i++) { url = urls[i]; try { urlconnection conn = url.openconnection(); conn.connect(); totalsize = conn.getcontentlength(); bufferedinputstream bis = new bufferedinputstream(url.openstream()); fileoutputstream fos = new fileoutputstream(environment.getexternalstoragedirectory().getpath() + "/forvo_temp.mp3"); bufferedoutputstream bos = new bufferedoutputstream(fos,1024); byte [] data = new byte[1024]; int x=0; int c=0; while((x=bis.read(data,0,1024))>=0){

php - API stop supporting JSONP -

i made simple api in php. api echo's object using json_encode. per example: echo json_encode($obj); i using jquery retrieve information api. when testing script , api, both running on same server. , worked fine. an example of jquery: $.ajax({ url: "php/api/test.php" datatype: "json", type: "post", succes: function(data) { console.log("success"); }, error: function(response) { console.log("error"); } }); now worked fine. since api running on external server not work anymore (yes changed url correct one). i had alter api , javascript in order use jsonp before jquery receive information api. my jquery is: $.ajax({ url: "http://externalserver/php/api/test.php" datatype: "jsonp", type: "post", succes: function(data) { console.log("success"); }, error: function(response) { console.log("e

How do I create a simple array from an array of array with JavaScript? -

i create array multidimensional array this: var dataitaly = [ /*town region city*/ ["castelspina","piemonte","alessandria" ], ["cavatore","piemonte","alessandria" ], ["cella monte","piemonte","alessandria" ], ["cereseto","piemonte","alessandria" ], ["cantarana","piemonte","asti" ], ["capriglio","piemonte","asti" ], ["casorzo","piemonte","asti" ], ["albino","lombardia","bergamo" ], ["algua","lombardia","bergamo" ], ["abbiategrasso","lombardia","milano" ], ["agrate brianza","lombardia","milano" ], ["aicurzio","lombardia","milano" ], ["almese","piemonte","tori

oop - How to assign Mandatory Properties in class object in C# -

im working on .net using c#. in c# classes want use optional properties, have person class, in have properties name,age,city , gender. public class person { public string name{get; set;}; public int age {get; set;} public string city {get; set;} public string gender {get; set;} } now assigned property values name,age , city. person objper = new person(); objper.name="abc"; objper.age="22"; objper.city="nyc"; string strresult = calperson(objper); now im passing person object 'objper' 1 method, returns property values of person in xml format below.im not passing value gender property. public string calperson(person objperson) { //"<xml><name>abc</name><age>22</age><city>nyc</city><gender></gender></xml>" return xml formated string. } while creating xml formatted string im getting gender node null value though not sending value it. i wan

Reading a paragraph from the command line on java console program -

the while loop in following program not terminate can't output in last line tries print variable paragraph console. there similar problems solutions not practicle , not them. please suggest solution. import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; public class test { public static void main(string[] args) throws ioexception { string line = ""; string paragraph = ""; system.out.println("enter text: "); inputstreamreader isr = new inputstreamreader(system.in); bufferedreader bufferedreader = new bufferedreader(isr); while ((line = bufferedreader.readline()) != null) { paragraph = paragraph + line + " "; } isr.close(); bufferedreader.close(); system.out.println(paragraph); }//method main ends here } the code while ((line = bufferedreader.readline(

Newbie trying to add images to Android ViewPager and Fragments -

hi i'm new programming. i'm struggling, limited knowledge, horizontal view swiping in android project. downloaded viewpager tutorial , implemented code project , works great but, shows text numbers (1,2,3,4,etc...). able horizontally view swipe images (with maybe text) , not numbers. i'm frustrated, tried mixing , matching code other viewpager tutorials crashes , throws errors can't understand. there simple changes make code able horizontally swipe images , text? thanks. main activity package com.project.viewswipingtest; import java.util.arraylist; import java.util.list; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.view.viewpager; public class page5 extends fragmentactivity { mypageadapter pageadapter; @override public void oncreate(bundle savedinstancestate) { sup

autocomplete - Eclipse Auto code completion -

as need press ctrl+space see auto-code guessed eclipse, there setting words of codes automaticaly shown eclipse , don't need press ctrl+space every time, xcode example. sorry english :( if open eclipse preferences , type "content assist" search box can configure auto-activation delay , auto-activation triggers different languages.

c - Structure char array usage -

i have problem understanding how works out : struct main_s { char test[1]; }; is 2 dimensional array test[1][x] ? example how pass string "hello world" field of structure ? char array[1][11] = { {"h","e","l","l","o"," ","w","o","r","l","d"} }; and main_s->test = array doesn't work, compiler gives error types, 1 char [] , char*. how pass string "hello world" field of structure ? you have first declare sufficient memory space test array contain desired string. "hello world" contains 11 charachters. array should contains @ least 12 elements struct main_s { char test[12]; }; and copy string array with: struct main_s m; strcpy(m.test, "hello world"); printf("%s\n", m.test) // display content of char array string if want declare 2d array: struct main_s { char test[3][13]; } struc

MySQL - How to measure the amount of space used by certain rows? -

i working on project management program, built on lamp stack. have tentatively chosen not provide each 1 of clients own database, rather combine business' data 1 large database. the first column in database tables business_id. row indicates business piece of data belongs to, keeps exposing business 1's data business 2. but try iron out billing kinks, useful able run cron job once month determine how database space each business using. here's question: there way mysql return number of bytes used rows business_id = 'x'? since billing information customer explicitly paying store, sum lengths of fields explicitly give you. (omit internal fields business_id , service_level_id , permissions , or whatever.) then, refer storage requirements , calculate. so, b number of bytes required numeric fields, , there 3 text fields txta, txtb, , txtc, instance: select business_id, count(*) * b + sum(length(txta) + length(txtb) + length(txtc)) b

search - searching/reporting with servicestack -

we have aging client/server based application clients connect directly our transactional database (ms sql server)... 99% of our business logic located in stored procedures. we've been toying around building servicestack api on top of existing database. eventually, we'd migrate business logic servicestack api , make sole entry point crud operations. makes sense in head except reporting , searching. my question this... allow crystal reports / excel / etc connect directly database pull data - makes writing reports flexible can join tables and/or write subqueries produce desired results. how comparable accomplished when make our servicestack api entry point database? is possible allow robust searching through servicestack api or there technology give same flexibility (joins, subqueries) , application tool build these reports in? thanks. i divide question in pieces , try give answer. if want single endpoint using servicestack api , have database ready he

javascript - Create List of Elements Added Through Dynamic Polling -

i have jquery function dynamically polls django view of mine every 10 seconds see if new data has been added: setinterval(function() { $.get('pollnewentries', {}, newentrysuccess) }, 10000); function newentrysuccess(result) { $.each(result, function(index, value) { var datestring = new date(value.fields.pubdate); datestring = datestring.todatestring() + " - " + datestring.totimestring(); var title = "<h1>" + value.fields.title + "</h1>"; var authoranddate = "<h4>" + value.fields.author + " - <time datetime='>" + value.fields.pubdate + "'>" + datestring + "</time>" + "</h4>"; var text = "<div class='cuttext'>" + value.fields.text; + "</div>"; var html = "<article class='text'>" + title + authoranddate +

Xcode Maven Plugin : adding extra headers -

the xcode maven plugin http://sap-production.github.io/xcode-maven-plugin/site nice maven plugin people maven , wan't avoid pain xcode dependencies, framework creation , such. it creates , installs lib , headers in repository. the headers bundled in .tar file during process. for reason, need edit tar file , add few files in before installing. i'm quite noob regarding maven, need ! how can modify on byproduct of maven before installed ? suppose can write script add files .taf, how can sure it's executed prior installation ? @redwarp - it's been while since question asked, i'll offer answer. you can configure maven plug-in's goal executed during particular phase in maven build lifecycle. pick phase that's executed before install phase. package may best phase edit tar file , add required files. the following generalized example (the focus should on phase , goal): <project> ... <build> <plugins>

Is there a way to perform binary math on binary strings in PHP? -

i'm working numbers far large php handle (ipv6 addresses in binary), work around i've formulated function convert addresses to/from binary strings (literally string of 1s , 0s). however, when comes subnet calculations easiest way know how use binary math. have no idea how i'd use binary math in instance since i'm technically dealing strings, not binary numbers. there way can binary math string representation of binary number? when working large binary numbers use gmp extension . accepts strings of arbitrary length parameters.

r - Select max or equal value from several columns in a data frame -

i'm trying select column highest value each row in data.frame. instance, data set such. > df <- data.frame(one = c(0:6), 2 = c(6:0)) > df 1 2 1 0 6 2 1 5 3 2 4 4 3 3 5 4 2 6 5 1 7 6 0 then i'd set column based on rows. data frame this. > df 1 2 rank 1 0 6 2 2 1 5 2 3 2 4 2 4 3 3 3 5 4 2 1 6 5 1 1 7 6 0 1 i imagine there sort of way can use plyr or sapply here it's eluding me @ moment. there might more efficient solution, ranks <- apply(df, 1, which.max) ranks[which(df[, 1] == df[, 2])] <- 3 edit: spaced!

PHP compare two objects with same properties but different properties values, get non-matching values -

i have these 2 objects contained in array: array (size=2) 0 => object(stdclass)[20] public 'name' => string 'john' (length=4) public 'surname' => string 'd' (length=1) public 'id_number' => string '924' (length=3) public 'file' => string '1001' (length=4) public 'arrival_date' => string '1368466111' (length=10) 1 => object(stdclass)[21] public 'name' => string 'john' (length=4) public 'surname' => string 'd' (length=1) public 'id_number' => string '924' (length=3) public 'file' => string '1002' (length=4) public 'arrival_date' => string '1368466190' (length=10) it great come 3 arrays or 3 objects following: array('name'=>'john','surname'=>'d','id_number'=>'924') - contains matching values array('file&

oop - Why the Functions aren't defined ? PHP -

what have can use standard php functions without creating instance of math_functions class ? <?php class math_functions { public static function evennumber($number) { return !($number & 1); } public static function natual_sum($n) { while ($n) { if (evennumber($n)) { $sum = $sum + $n; } $n--; } return $sum; } } echo natual_sum(4); ?> this static function. have access using class name. use this math_functions::natual_sum(4);

uitableview - Creating an editable Table View in iOS? -

Image
i trying create editable table view in ios using .xib files. my code looks : viewcontroller.h #import <uikit/uikit.h> @interface viewcontroller : uitableviewcontroller @property (nonatomic, strong) nsmutablearray *notes; @end viewcontroller.m #import "viewcontroller.h" #import "note.h" @interface viewcontroller () @end @implementation viewcontroller - (id)initwithstyle:(uitableviewstyle)style { self = [super initwithstyle:style]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; [self setediting:no animated:no]; } - (void)viewwillappear:(bool)animated{ self.notes = [[note savednotes]mutablecopy]; [self.tableview reloaddata]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } #pragma mark - button events - (void)setediting:(bool)editing animated:(bool)animated { [super setediti