Posts

Showing posts from May, 2010

Ranges with different step size for odd and even steps in MATLAB -

what fastest , simplest way generate array like [0, 1, 3, 4, 6, 7, 9, 10, ...] in matlab? you can obtain cumulative sum of vector of steps (in case [1 2 1 2 1 2 1 2 ...] ). example: x = cumsum([0, repmat([1 2], 1, 4)]) x = 0 1 3 4 6 7 9 10 12

IOS: How to read specific data in one list of XML -

when use nsxmlparser parse xml in iphone app, know how in scenario this: > <title>l3178 : freiensteinau richtung grebenhain</title> // xml but, if want extract data list, e.x. want lat , lon <>id>, how should deal that? <>id> http://www.freiefahrt.info/?id=468b0243-e15c-4580-9ad2 14d8cf692999&lon=9.3495&lat=50.49465&country=de&filter=0&expires=2013-12-20t03:13:00 <>/id> it strange if use instead of <>id>, disappear. so, have use ugly notation. thank in advance! create method extracts parameters urlstring - (nsdictionary *)paramsfromurlstring:(nsstring *)urlstring { nsrange range = [urlstring rangeofstring:@"?"]; nsstring *substring = [urlstring substringfromindex:range.location+range.length]; nsarray *components = [substring componentsseparatedbystring:@"&"]; nsmutabledictionary *params = [nsmutabledictionary dictionary]; (nsstring *string in c

java - How to do yahoo integration in Android? -

i'm developing yahoo login integration in android app , return main activity. have completed steps of yahoo integration.i have spent several days searching yahoo integration in android cant find proper way.when run code , proper sign in yahoo email , when click agree button comes call_back url. please can mi.here code public class requesttokaenactivity2 extends activity { private oauthconsumer consumer; private oauthprovider provider; private sharedpreferences yahooprefs; private commonshttpoauthconsumer myconsumer; private commonshttpoauthprovider myprovider; private string requesttoken; private string accesstoken; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); try { consumer=new commonshttpoauthconsumer(c1.consumer_key,c1.consumer_secret); consumer.setmessagesigner(new hmacsha1messagesigner()); httpclient httpcliet=new defaulthttpclient()

html - '&' inside a parameter breaks url -

i have problems character '&' in url. have 3 string , in 1 of there text character '&'. example: "monsters & co." i have take 3 string pass them in url page. example: <a href="http://www.pageexaaa.com?param1=aaa&param2=bbb&param3=monsters & co.">link</a> but on second page can see third parameter monsters because url thinks & new parameter. how can do? everyone. replace & %26 forexample see url http://www.google.com/search?sourceid=chrome&ie=utf-8&q=%26 so in case <a href="http://www.pageexaaa.com?param1=aaa&param2=bbb&param3=monsters %26 co.">link</a>

c++ - Internet Explorer BHO, writing to registry and admin privileges -

for reasons when try write registry when ie doesn't run admin privileges, utils::setvalueinregistry(hkey_current_user,l"software\\myapp23",l"domain", value.c_str()); anyone knows how gain bho rights write registry everytime? or maybe should write section registry that's available writing? information need store dynamic , used in order communicate between tabs. thanks. internet explorer running low integrity level. use key below hkey_current_user\software\lowregistry

actionscript 3 - Upload video to YouTube via V3-API with Flex/AS3 -

i working on air-application upload videos youtube. since got absurd requirement upload files 80gb (we not need discuss this, think it´s nonsense) decided use resumable upload uploading chunks, descriped on https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol but reason, if add content-range header, receive error #2032. if not add content-range header, upload works, first chunk. has managed upload file v3 api in as3/flex ? error 2032 occurs when program or running application goes non-responsive. common reasons this.. your proxy settings may not valid your website must in list of restrictions your cookies must corrupted your add-on's on browser may responsible your registry must corrupted source : adobe forums

mysql - Select Count of ip and Count of DISTINCT ip in same query -

i have table structure this: table name : counter id | datetime | url | ip ------------------------------------------- 1 |2013-04-12 13:27:09 | url1 | ip01 2 |2013-04-13 10:55:43 | url2 | ip02 3 |2013-04-14 11:14:12 | url1 | ip03 4 |2013-04-15 23:23:55 | url2 | ip04 5 |2013-05-02 08:34:44 | url1 | ip03 with smart select query, want fetch 3 columns are: distinct url | count of ip | count of distinct ip | each distinct url | each distinct url ------------------------------------------------------------------- url1 | 3 | 2 url2 | 2 | 2 i came query below by of solution in stackoverflow gives me first 2 columns need: select url, count(*) total_ip counter group url order total_ip desc but how can add 3rd column query? can please me? as mentioned yourself, can use distinct keyword distinc

Consuming java web service in android application -

Image
as shown in below screenshot, have created web service(in java) , client application(android app) following this article . i got build successful message after creating ant build file under section create web service client in article , under client app 8 files generated shown in image(2) below. now when write hellowebservice service = new hellowebservice(); in client app, app crashes , following exception: java.lang.noclassdeffounderror: com.mycompany.service.client.hellowebservice am doing wrong? any appreciated. i don't know environment exception lead hellowebservice class not found @ run time. means have not placed jar containing 'hellowebserice' class in classpath when run application. surely have jar when compile code compiles unfortunately not found jvm @ run time. try putting jar in classpath , should good.

xml - Functions and subselects in single FLWOR -

i'm writing xquery analyse large numbers of xml files store queries similar example below. these queries i'd calculate averages, sums , other information on various subelements. additionally i'd generate subsections of queries in same document, instance queries have no hits. as i'll manipulating hundreds of thousands of xml files, i'd make xquery efficient possible. i've tried use single for iteration across documents cannot figure out how derive information need. here's sample xml: <query> <querystring>gigabyte sapphire gtx-860</querystring> <statuscode>0</statuscode> <querytime>0.04669069110297385</querytime> <hits>8</hits> <date>2013-05-02</date> <time>12:07:07</time> <lastmodified>12:07:07</lastmodified> <pages resultsperpage="10" clickcount="2"> <page resultcount="8" visited="true">

jsf 2 - change h:inputText attribute with javascript jsf2 -

i have input : <p:column headertext="quantité"> <h:inputtext styleclass="maqte" id="qte" onkeyup="validerinput($(this),$(this).parent().prev().find('.monpu'));" value="#{car.qte}" converter="lenientdoubleconverter" > </h:inputtext> </p:column> as shown in code above ( converter="lenientdoubleconverter" ) i use converter (to disable implicit conversion of jsf2) but after when user click on 1 button want enable it, should remove converter javascript before request sent ther server is there way remove attribute javascript thank in advance is there way remove attribute javascript no. rightclick page , view source in favourite browser. you'll see jsf code produces 1 , html code. jsf component's converter attribute represented in generated html output of <h:inputtext> . more, converter doesn't r

mysql - SQL cmd remote connection and database import -

i need access external database import sql file through windows cmd. line not working , i´m wondering what´s problem since must easiest way it. want way becausei´m told solve problem of importing sql database file exceeds limitation size , don´t have access php.ini mysql -u user -p pass --host=ip databasename| file.sql i believe default behaviour of mysql not permit remote access - have owner set (and modify firewall approprite). i'm sure obvious, anyway... need have mysql installed on machine, , pretty sure have watch versions (i think there may switch connect different version).

How to refer to Excel columns without headers in TSQL -

i dived documentation since didn't find information (well, found similarities other questions not want), i'm asking guys me : i'm executing tsql query on adodb connection, retrieve data excel file (*.xlsx) one. file composed follow : header1 header2 header3 --------- --------- --------- a1 b1 c1 a2 b2 c2 a3 b3 c3 .... .... .... i want retrieve headers here's part of whole program, containing connection string dim con adodb.connection dim rs adodb.recordset set con = new adodb.connection set rs = new adodb.recordset con .provider = "microsoft.ace.oledb.12.0" .connectionstring = "data source=path\file.xlsx; _ extended properties=""excel 12.0 xml;hdr=no;imex=1""" set rs = .execute("select * [sheet1$]") .close end here retrieve columns, if want column b, column a, column c, e.g. : set

Trying to add html w/ link using echo after else in php -

i have content available registered users - guests see intro if click read more shown message login or register - need add link registration page in message see. here have tried: if (!$user->guest) { echo $this->item->fulltext; } else echo '<h3><b>please login or <a herf="/login/register">register</a> view entire article</b></h3>'; ?> my text shows correctly & word register turns blue, not linking. please advise. thank in advance. when can tell me herf is, i'll wonder myself. it's spelled href not herf . => <a href="/login/register">register</a>

linq - Dynamically pass Type to Method<T> -

i've method , retrieves me data according type passed in parameter, : protected void filllist<tentity>() { doworkfortentity(); } i need dynamically call method : type[] entities = system.reflection.assembly.getassembly(typeof(user)).gettypes(); type currententity = (from entity in entities entity.name.equals(this.targetentity) select entity).firstordefault(); filllist<currententity>(); i got error : the type or namespace name 'currententity' not found (are missing using directive or assembly reference?) i've tried intermediate object type, no success any idea please ? since there no information entity type in compile time, need construct , call appropriate method reflection: type[] entities = system.reflection.assembly.getassembly(typeof(user)).gettypes(); type currententity = (from entity in entities

python - Matplotlib on click get node -

i want change color on node clicked on def button_press_callback(event): print event.x this event add figure: wm.canvas.mpl_connect('button_press_event', button_press_callback) i want detect on node clicked , change color of node. when try ind property event object, exception thrown: ind = event.ind[0] attributeerror: mouseevent instance has no attribute 'ind' but in examples see other users can ind property.

python - create static html pages dynamically cos of SEO -

i trying how create static html pages dynamically. because reading dynamic content not google friendly, google cannot crawle content coming database once page opened. in exact example: {{ content_from_db }} this variable replaced long text. long text contains many important keywords of page. read content unfortunately not seen google since dynamic. then said, lets create static html pages dynamically, stuck here not knowing how.. is possible? your premise , utterly false. absolutely not case google can't index dynamically created websites. of course can: stackoverflow, has awesome seo, 1 of millions of dynamic websites indexed google.

android - Open Dialog bound to another Context -

i have activity (documentactivity.java) bounded context dialog (documents_link_onclick_dialog.xml). on dialog want open when click on button dialog (documents_link_editlink.xml) time dialog should have activity (urlactivity.java). tried these 4, none of these worked. // try 1 new urlactivity().showdialog(r.layout.documents_link_editlink); // try 2 startactivity(new intent(this, urlactivity.class)); // try 3 dialog.setcontentview(r.layout.documents_link_editlink); dialog.show(); // try 4 final dialog dialog2 = new dilog(urlacitivty.this); dialog2.show() what doing wrong? hope can me :) here find relevant classes: androidmanifest.xml <activity android:name=".documents.urlactivity" android:label="@string/documents_link_edit_activity_title" android:theme="@android:style/theme.black" > <intent-filter> <action android:name="de.hsaugsburg.hsapp.documents.intent.action.view" /> <

Web Controls Not Talking to Each other in ASP.NET using VB.NET -

i have asp.net page loads 2 controls, control , control b. control has generic form submit , clear buttons trigger click events in its' own code behind use reflection call update function in control b has few input fields. have debugged , seems in order, however; when update function in control b called input fields not returning value when using inputname.text or me.inputname.text. have ideas why not working? guidance appreciated. this code in control a's codebehind calls update method in control b's code behind protected sub btnsave_click(byval sender object, byval e eventargs) handles btnsave.click try dim lctlcontrol = session("selectedqstnctl") dim methodobj = lctlcontrol.gettype().getmethod("updategeninfo", bindingflags.nonpublic or bindingflags.instance) ' execute updategeninfo method update data methodobj.invoke(lctlcontrol, nothing) catch ex exception 'todo: check concurrency e

java - GUI not showing up initially (netbeans) -

i'm new java , newer netbeans.. cannot figure out how fix issue.. when run project gui doesn't show up. there should menu bar drop down opening , saving file, , exiting program. there should 3 buttons towards bottom of window can used display data within file (images in case). instead, window blank when run program, nothing shows @ all. when click on top left hand corner, 'file' resides on menu bar.. shows , top button shows @ point too. second 2 buttons should greyed out , become click-able after you've clicked first button , displayed first image. i've tried searching solution, , fiddling netbeans settings can't seem solve this. i'm assuming it's stuff being incorrectly placed in foreground or background i'm unsure. also, i've discovered if remove drawimage bit of code ((public void paint (graphics g) {g.drawimage(imagetopaint, 50, 70, this);}) gui shows i'm guessing conflicting something.. somewhere?! thanks in advance if

Implementing Matlab's colon : operator in C++ expression templates class -

i'm implementing c++ expression templates library. have set proper submatrixexpr class collect elements within matrix, enabling syntax like b = submatrix(a,1,3,2,10); which equivalent matlab's b = a(1:3,2:10); of course, matlab's syntax more confortable mine. question is is there possibility set matlab's colon : operator in c++? thank in advance. short answer: no. colon not valid c++ operator, cannot overloaded. , if could, still not possible achiev need easily, because surely have precedence on comma operator, make expression in lines of a((1:3),(2:10)) , , allowed overload operators if 1 of operands user defined type (which not case here). so other operator in place, not looks this. what can do: overload operator() matrix class, sensible arguments. enable write b = a(1,3,2,10); , if define operator()(int,int, int, int); my preferred solution operator() taking either 2 initializer_list s in c++11 or 2 std::array<int,2> . forme

arrays - Get Some Value from Random Function in PHP -

i have 5 value generating random function in php this: 1 0 0 1 1 and code: for ($i=0; $i<10; $i++){ $n = rand(0, 1); echo $n;echo "<br/ >"} and now, should value first row , third? value: 1 0 use array store data , access it: for ($i=0; $i<10; $i++){ $data[] = rand(0, 1); } echo $data[0]; //1st "row" echo '<br>'; echo $data[2]; //3rd "row" keep in mind php arrays start index 0. learn more php arrays , usage: http://php.net/manual/en/language.types.array.php

Heroku + Rails + GeoIp = uninitialized constant GeoIP error -

i'm trying deploy old website heroku. goes well, starts, when access through web browser get nameerror (uninitialized constant applicantscontroller::geoip): i'm using rails 2.3.18 (my website simple , want deploy "as is" , asap; on dedicated server worked well). i have geoip.dat file in 'db' folder , in controllers/applicants_controller.rb have line 32: geoip ||= geoip.new("db/geoip.dat") line 33: location = geoip.country('google.com') if launch irb on heroku looks good: login@sancho:~$ heroku run bash running `bash` attached terminal... up, run.7785 ~ $ irb irb(main):001:0> require 'geoip' => true irb(main):002:0> geoip ||= geoip.new("db/geoip.dat") => #<geoip:0x00000002b3a6a8 @mutex=#<mutex:0x00000002b3a680>, @flags=0, @database_type=1, @record_length=3, @file=#<file:db/geoip.dat>, @database_segments=[16776960]> irb(main):004:0> geoip.country('google.com') =>

javascript - script to call other php page not working -

need help, button not working, report generator button main page not calling report.php page, in chrome, i've checked network tab under developer tools , im not getting activity/response when click report generator button, below main php page: <script type="text/javascript"> $(document).ready(function(){ $("#retrievelist").on('click',function() { var xid = $('#xid').val(); var date = $('#date').val(); $.post('retrieve_test.php',{xid:xid, date:date}, function(data){ $("#results").html(data); }); return false; }); $("#deletefromdb").click(function() { if (confirm("are sure want delete?")) var id = $('input[name=checkbox]:checked').map(function() { return $(this).val

javascript find an object with specific properties in an array -

i need make extension existing code, can't change it. there's array: var availabletags = [ { label: "yoga classes", category: "educational" }, { label: "cooking classes", category: "educational" }, { label: "cheese tastings", category: "educational" }, { label: "maker workshops", category: "practical" }, { label: "seminars", category: "practical" }, //many more of these ]; now need check if text entered in input box included in 1 of labels, e.g. if user enters "yoga classes" => ok, if "yoga" => nok, "sdsdf" => nok, etc. what best way this? not sure can use array.indexof not sure how pass object function, try looping through array (around 40 entries) , compare each object. you can use array.some method: tests whether element in array passes test implemented provided func

Rails 4: checkboxes with a has_many through -

i'm building application has assign assignment multiple employers. i have build these models: #assignment.rb class assignment < activerecord::base has_many :employer_assignments has_many :employers, :through => :employer_assignments end #employer.rb class employer < activerecord::base has_many :employer_assignments has_many :assignments, :through => :employer_assignments end #employer_assignment.rb class employerassignment < activerecord::base belongs_to :employer belongs_to :assignment end and want form save employer_assignment table following code used form doesn't work. <div class="field"> <%= f.label :employer_ids %><br /> <%= collection_check_boxes(:assignment, :employer_ids, employer.all, :id, :name) %> </div> i did add :employer_ids assignment controller try send form create assignment doesn't create records in employer_assignment table. when add them via console (

python - How to Clean Up subprocess.Popen Instances Upon Process Termination -

i have javascript application running on python / pyqt / qtwebkit foundation creates subprocess.popen objects run external processes. popen objects kept in dictionary , referenced internal identifier js app can call popen 's methods via pyqtslot such poll() determine whether process still running or kill() kill rogue process. if process not running more, remove popen object dictionary garbage collection. what recommended approach cleaning dictionary automatically prevent memory leak ? my ideas far: call popen.wait() in thread per spawned process perform automatic cleanup right upon termination. pro : immediate cleanup, threads not cost cpu power should sleeping, right ? con : many threads depending on spawning activity. use thread call popen.poll() on existing processes , check returncode if have terminated , clean in case. pro : 1 worker thread processes, lower memory usage. con : periodic polling necessary, higher cpu usage if there many long-running

javascript - jQuery plugin tutorial explanation -

i'm following jquery plugins/authoring tutorial, , couldn't figure out arguments on lines 16 , 18 mean. missing fundamental? (function( $ ){ var methods = { init : function( options ) { // ... }, show : function( ) { // ... }; $.fn.tooltip = function( method ) { // method calling logic if ( methods[method] ) { return methods[ method ]. apply( this, array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return methods.init.apply( this, arguments ); } else { $.error( 'method ' + method + ' not exist on jquery.tooltip' ); } }; })( jquery ); thank you. arguments array-like object contains parameters passed function, including parameters didn't supply variable name for. it array-like, not array. not contain of array methods, such slice, why have use array.prototype.slice.call(arguments,...) or [].sl

java - Correct way to set the socket send buffer size on linux? -

i have nio server gets small client requests result in ~1meg responses. server uses following accept new client: socketchannel clientchannel = server.accept(); clientchannel.configureblocking(false); clientchannel.socket().setsendbuffersize(2 * 1024 * 1024); i log out "client connected" line includes result of clientchannel.socket().getsendbuffersize(). on windows, set changes client socket's send buffer size 8k 2megs. on linux, socket says send buffer 131,071 bytes. this results in lousy performance, clientchannel.write writes 128k @ time, takes 7 more passes data written. on windows, setsendbuffersize change improved performance. linux appears configured allow large socket send buffer: $ cat /proc/sys/net/ipv4/tcp_wmem 4096 16384 4194304 the platform free adjust requested buffer size or down, , that's linux appears doing. nothing can except maybe tune maxima via kernel configuration. note comments in question linked setting buffe

ajax - Dictionary in JavaScript -

currently tried reform json data dictionary store needed data in array key , value. * edit put full code. * this how do: var mydata = []; var urlpath = "https://tipjira.pgdev.abcd.com/rest/api/2/search?jql=project=grifr14%2band%2bfixversion=15018"; var jiramapping = []; $.ajax({ url : "http://frparwself22.dhcp.par.abcd.com:8080/jiraproxy/jira?url=" + urlpath, datatype : 'json', type: 'get', success : function(data) { (var i=0; i<data.issues.length; i++) { var obj = {}; obj[data.issues[i].key] = data.issues[i].self; jiramapping.push(obj); alert(jiramapping.length); } }, error : function() { alert("error!") } }); alert(jiramapping.length); my original data {issues:[{...,"self":"/rest/api/2/issue/175074","key":"grifr14-36",...}, {...,"self":"/rest/api/2/issue/175075&q

ruby - Rails won't save to database after tiny model manipulation -

i'm coding first rails app @ moment , can't resolve annoying error. what want do: app connected user's dropbox account. user can specify path in app looks audio files. these audio files shall downloaded, metadata, path, etc saved song model in database, belongs_to corresponding user. i implemented method indexes dropbox folder , saves filename , direct link few weeks ago. added line saves entire dropbox path database , of sudden nothing saved anymore. this song model looks like: require "dropbox_helper" require "open-uri" class song < activerecord::base belongs_to :user attr_accessible :artist, :expiration, :is_cached, :length, :dropbox_link, :local_path, :title, :dropbox_path validates_presence_of :title, :is_cached, :dropbox_link, :dropbox_path #validates :dropbox_path, :uniqueness => true def self.fetch_basic_songdata(user) logger.info "++++debug: song#fetch_basic_songdata started" dbh = dropboxhelper.