Posts

Showing posts from September, 2011

android-How play youtube video from default application -

i using code load youtube video launching intent let user choose video application use: startactivity(new intent(intent.action_view, uri.parse("http://www.youtube.com/watchv=cxlg2wte7tm"))); by doing able load youtube webpage , user need click play button play video,then video starts play.how can avoid intermediate step. look @ post maybe android youtube app play video intent and here official documentation : https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/package-summary

c++ - Convert string to const char* issue -

this question has answer here: how convert std::string const char* or char*? 8 answers string str1 = "hello"; const char* string1 = str1; i error.. cannot convert ‘std::string {aka std::basic_string}’ ‘const char*’ in initialization how cast string const char* thanks helping how cast string const char*? use std::string::c_str() function, returns non-modifiable standard c character array version of string. const char* string1 = str1.c_str();

python - Why would a django UpdateView return a 404 until the server was restarted? -

i have following create , update views (django 1.5, python 2.7): class newscreateview( permissionrequiredmixin, createview ): model = news template_name_suffix = "_create_form" form_class = newsform login_url = "/login/" permission_required = "news.add_news" def get_context_data(self, **kwargs): # call base implementation context context = super(newscreateview, self).get_context_data(**kwargs) context['tags'] = news.tags.all() return context def form_valid(self, form): obj = form.save(commit = false) obj.slug = slugify(obj.headline) obj.writer = self.request.user.person obj.pub_date = datetime.datetime.now() obj.featured = false obj.enable_comments = true return super(newscreateview, self).form_valid(form) class newsupdateview( permissionrequiredmixin, updateview ): model = news

jquery mouseover not staying selected -

i using tutorial create flip wall: http://tutorialzine.com/2010/03/sponsor-wall-flip-jquery-css/ in tutorial flip element triggered .click event, change .mouseover event. i ahve setup demo here using .mouseover event. when hover on images , move mouse images flip back. heres js: edit: updated code $(document).ready(function(){ var valid = false; $('.sponsorflip').bind("mouseenter",function(){ elem = $(this); if(!valid){ // using flip method defined plugin: elem.flip({ direction:'lr', speed: 250, onbefore: function(){ // insert contents of .sponsordata div (hidden view display:none) // clicked .sponsorflip div before flipping animation starts: elem.html(elem.siblings('.sponsordata').html()); } }); // setting flag: elem.data('flipped',true); valid = true; } }); $('.s

PyQt QWidget in QAbstractListModel gets deleted with QSortFilterProxyModel -

i need populate listview widgets, have custom proxyfilter work it. without filter works great, when active seems delete widgets attach model. it shows fine showing items, filtering works when erasing filter, when hidden widgets should shown again following error gets thrown: custom_widget.setgeometry(option.rect) runtimeerror: underlying c/c++ object has been deleted tried not using qvariant , going internalpointer route breaks @ same spot. thanks having look! setup: def __init__(self, *args): qtgui.qwidget.__init__(self, *args) # create temp data self.list_data = [] x in xrange(500): widget = listitemwidget(text=str(x), parent=self) self.list_data.append((str(x), widget)) # testing put in inmut tuple # create listviewmodel self.lm = listviewmodel(parent=self) # create listview widget self.lv = qtgui.qlistview() # create filter proxy self.proxy_model = listviewfilterproxymodel() self.proxy_model.setf

java - ActiveMQ negative AverageEnqueueTime -

i'm facing strange issue on network of brokers, amq 5.8.0. checking times on jconsole can see negative averageenqueuetime values. same applies querying such values in programmatic way using following code: string jmxurl = "service:jmx:rmi:///jndi/rmi://" + mybrokeruri + ":1098/jmxrmi"; jmxserviceurl url = new jmxserviceurl(jmxurl); jmxconnector connector = jmxconnectorfactory.connect(url, null); connector.connect(); mbeanserverconnection connection = connector.getmbeanserverconnection(); topicviewmbean topicmbean = (topicviewmbean) mbeanserverinvocationhandler.newproxyinstance(connection, mytopicname, topicviewmbean.class, true); topicmbean.getaverageenqueuetime(); using 1 broker, in same enviornment, can see right values (positive , meaningful). any idea this? thank much best cghersi

css - How to apply a webkit linear gradient to all the other prefixes? -

i have created following linear gradient webkit background-image: -webkit-repating-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 62px, black 62px, black 63px); im unsure how create same style in opera, mozilla etc. can advise how can achieved? background: -moz-linear-gradient(top, rgba(0,0,0,1) 62px, rgba(0,0,0,1) 63px); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(62px,rgba(0,0,0,1)), color-stop(63px,rgba(0,0,0,1))); /* chrome,safari4+ */ background: -webkit-linear-gradient(top, rgba(0,0,0,1) 62px,rgba(0,0,0,1) 63px); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(top, rgba(0,0,0,1) 62px,rgba(0,0,0,1) 63px); /* opera 11.10+ */ background: -ms-linear-gradient(top, rgba(0,0,0,1) 62px,rgba(0,0,0,1) 63px); /* ie10+ */ background: linear-gradient(to bottom, rgba(0,0,0,1) 62px,rgba(0,0,0,1) 63px); /* w3c */ filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#000000', endcolorstr='#000000',gr

asp.net mvc - web api call from code behind -

i new mvc web api i have crated web api post method takes object type "bag" , return htmlstring code shown bellow public htmlstring postbag(bag bagofitem) { return utility.postbagdiscounteditem(bagofitem); } now web site wanted call api method postbag controller postbag() and not know how , appreciate if 1 can show me how this what have got in web application bellow. public class homecontroller : controller { private bag _bag = new bag(); private string uri = "http://localhost:54460/"; public actionresult postbag() { // 1 show me how post _bag api method postbag() return view(); } public class bag { private static list<product> _bag { get; set; } public list<product> getbag () { if (_bag == null) _bag = new list<product>(); return _bag; } } try this: using (var client = new httpclient()) { client.baseaddress = new uri(&

mysqli - Filter out closest dublicated rows (but not completely all) from MySQL table -

in table need filter out nearest dublicated rows have same status_id (but not all) when user_id same. group by or distinct did not in situation. here example: --------------------------------------------------- | id | user_id | status_id | date | --------------------------------------------------- | 1 | 10 | 1 | 2010-10-10 10:00:10| | 2 | 10 | 1 | 2010-10-11 10:00:10| | 3 | 10 | 1 | 2010-10-12 10:00:10| | 4 | 10 | 2 | 2010-10-13 10:00:10| | 5 | 10 | 4 | 2010-10-14 10:00:10| | 6 | 10 | 4 | 2010-10-15 10:00:10| | 7 | 10 | 2 | 2010-10-16 10:00:10| | 8 | 10 | 2 | 2010-10-17 10:00:10| | 9 | 10 | 1 | 2010-10-18 10:00:10| | 10 | 10 | 1 | 2010-10-19 10:00:10| have like: --------------------------------------------------- | id | user_id | status_id | date | ------------------------------------

jquery - Spinner, step, count value -

i've used jquery-ui (1.9.2) , create calculating functions. bind them on select inputs, , can see how work here jsfiddle i don't know how make similar calculation function "spinner". example 1 step should equal ( x )$; <input type="spinner" class="spinner" value="0" max="10" min="0" data-fieldname="spinner_count" data-days="13" data-price="22"> for have this: http://jsfiddle.net/strix/bqjpm/

navigation between views in flex from popup -

Image
i work on flex application. have following problem :in fact, in first page popup of authentification appears closed if user exists in database. part works correctly, in popup make link helps user recover account. problem didn't know how navigate page of recovering email, use state didn't work please can me . code of authentification popup <?xml version="1.0" encoding="utf-8"?> <s:titlewindow xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:services="services.*" x="400" y="400" width="400" height="196" cornerradius="10" creationcomplete="doinit();" fontsize="12" title="authentication" xmlns:local="*"> <fx:declarations> <s:callresponder

java - Spring MVC interceptor - intercept all request -

i want interceptor requests. problem interceptor captures links http://localhost:8080/car/cardetails/105303/?currencycode=usd , doesn't captures links http://localhost:8080/index.jsp?pagename=oldlegacypage&currencycode=usd&locale=en . the interceptor used translate legacy links. couldn't make intercept request starting index.jsp this configuration did in servlet-context.xml (spring version 3.1.1.release): <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- controller mapping configuration --> <interceptors> <interceptor> <mapping path="/**" /> <beans:bean class="com.mydomain.interceptor.legacyrequestinterceptor" /> </interceptor> </interceptors> <default-servlet-handler /> thank you update: seems works if modify servlet mapping / /* of dispatcherservlet: <servlet-mapping> <servlet-name>

linux - Getting the address of a function in C? -

i'm getting segfault when running code root in userspace. don't understand why. believe have rootkit , want check if addresses same ones in /boot/system.map-3.2.0-4-amd64 unsigned long hex; unsigned long **sys_call_table; for(hex = 0xffffffff810f8989; hex < 0xffffffff8160e370; hex += sizeof(void *)) { sys_call_table = (unsigned long **)hex; if(sys_call_table[3] == (unsigned long *)0xffffffff810f8989) { puts("sys_close's address has not been replaced rootkit"); } } cat /boot/system.map-3.2.0-4-amd64 | grep "string want" ffffffff81401200 r sys_call_table ffffffff810f9f9e t sys_read // sys_call_table[0] ffffffff810fa009 t sys_write // sys_call_table[1] ffffffff810f950d t sys_open // sys_call_table[2] ffffffff810f8989 t sys_close // sys_call_table[3] ffffffff8160e370 d loops_per_jiffy running root not enough - problem run in user space - run in kernel space , kernel module, examp

Intent does not work in on click function -

i trying move 1 activity using intents. intent object fired on function not working application crashed whenever pushes button. firstactivity class bt_open function public void bt_open(view v) { intent i= new intent(map.this,filechooser.class); startactivity(i); } have put filechooser activity in manifest.xml? every activity should defined in manifest.xml .

objective c - Adding UITableView to existing UIViewController -

i have uiviewcontroller open camera, after doing imagepickercontroller:didfinishpickingmediawithinfo: uitableview shall shown. somehow tableview delegation code not triggered. tableview shown on iphone empty rows. seems ib stuff displayed without code. cannot figure out missed. how uitableview working? mainstoryboard.storyboard camera view controller scene ---------------------------- camera view controller view image view // hooked .h table view // hooked .h table view cell - clocation cameraviewcontroller.h #import <uikit/uikit.h> @interface cameraviewcontroller : uiviewcontroller <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate, uitableviewdatasource, uitableviewdelegate> @property (weak, nonatomic) iboutlet uiimageview *imageview; // hooked ib uiimageview @property (strong, nonatomic) nsmutablearray *locations; @property (strong, nonatomic) iboutlet uitableview *tableview; // hooked ib uitableview @end

Mysql query to get data which has single quotes in the field data? -

i have query $qry="select * post_prop project='abinandan's kailash' , builder_name='abinandan-foundations-pvt-ltd'"; but iam not getting results? escape quotes double quotes: $qry="select * post_prop project='abinandan''s kailash' , builder_name='abinandan-foundations-pvt-ltd'"; you should enable display_errors , error_reporting in php.ini and/or remove @ in front of *_query command (if present) in order display errors. way, php have warned there syntax error.

iphone - I converted CAF to AAC format using TPAACAudioConverter but converted file duration is 0 -

i'm using avaudiorecorder. record sound in caf format. after convert file caf aac format using tpaacaudioconverter . works fine converted file duration 00:00. there way duration of aac audio file. the aac format doesn't support simulator.you can check on device. works fine , may aac audio file duration.

ruby - How to sort and remove duplicates in an array? -

i have compare 2 csv files populated ecommerce. files similar, except newer ones have different number of items, because catalogue changes every week. example of csv file: sku_code, description, price, url 001, product one, 100, www.something.com/1 002, prouct two, 150, www.something.com/2 by comparing 2 files extracted on different days, produce list of products have been discontinued , list of products have been added. my index should sku_code, univocal inside catalogue. i've been using this code stackoverflow : #old file f1 = io.readlines("oldfeed.csv").map(&:chomp) #new file f2 = io.readlines("newfeed.csv").map(&:chomp) #find new products file.open("new_products.txt","w"){ |f| f.write((f2-f1).join("\n")) } #find old products file.open("deleted_products.txt","w"){ |f| f.write((f1-f2).join("\n")) } my issue it works well, except in 1 case: when 1 of fields after sku_

Java, JNI and C++: How do I generate a header file from native method declarations? -

java, jni , c++: how generate header file native method declarations? i have java project, communicates c++ code through jni. challenge need add new methods. first started declaring native methods in java code. need regenerate header file jni methods. work in eclipse, not sure how this. i used using command line. go source file directory. javac filename.java generate filename.class file. javah filename generate filename.h file. you may refer javac , javah more help.

change Default font for Android App -

okay, know how change font used on individual textboxes in app, want text in app use custom font , color, , way can think of reference each box , set them proper font , color. while it's doable seems rather clunky method, there better way? you can create custom textview , reffer everywhere. public class typefacedtextview extends textview { public typefacedtextview(context context, attributeset attrs) { super(context, attrs); typeface typeface = typeface.createfromasset(context.getassets(), fontname); settypeface(typeface); } } inside view.xml <packagename.typefacedtextview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello"/>

java - Calling a method from GamePanel -

i believe pretty simple oo question can't seem find answer :/ have game panel load of balls painted onto panel. when ball hits bottom of panel game on message should displayed. the problem i'm dealing regarding game on joptionpane . believe should kept in class need call in ball class. here part of ball class want call method (marked **): private void moveball() { if (x == panel.getwidth() - size) { xa -= speed; } else if (x < 0) { xa += speed; } if (y == panel.getheight() - size) { ya -= speed; } else if (y < 0) { ya += speed; } if (collision()) { ya = -speed; y = platform.gety() - diameter; } if (y == panel.getheight() - size) { // ***call gameover here*** } x += xa; y += ya; } here constructor being called ball class in game panel: // constructor pass colour , platform public ball(jframe frame, jpanel panel, platform platform, color colour,

Best framework for REST API Client -

i've finished develop rest api using play 2 , i'm starting think client. need buill backoffice users allowing them manage data (stored in play2 database). nothing saved in database in client part, every creation/edition/deletion done via api. so "best" framework developing kind of api client ? i'm used develop in java or php can use other languages. read guzzle, have tried ? thanks answers. can't (or shouldn't you) using play too? mvc framework, , allows create nice interfaces... should 1 of "views" of application. if want/have develop different application, pretty sure play allows consume server rest api too. should not looking other frameworks if know play... "subjective choice"... why there not "best one" everyone.

C# safely build an SQL string to execute using Entity Framework -

i'm executing sql using ef .sqlquery(string sql) command. i want make sure sql string sanitised, logic approach use sqlcommand object parameters build it. however don't want execute using sqlcommand, want sqlcommand spit out string can plug ef .sqlquery(...) call. is there way of doing this, or method of ensuring .sqlquery won't result in injection? doesn't ef support out of box? you should able call sqlquery parameters, take care of sql injection etc., sqlcommand does: var tests = context.database.sqlquery<test>( @"select id, name tests name={0}", "testname"); or.. var tests = context.database.sqlquery<test>( @"select id, name tests name=@name", new sqlparameter("@name", "testname"));

mysql - What is the simplest way to run a script when an email is received? -

i'd run script, typically in php or mysql since involves changing mysql db table when email arrives @ exchange server (2010). the server holds iis7. so in short: email->exchange server->changes table in mysql db notes: not looking script connects e-mail via pop/imap i'm looking kind of trigger occurs in server webservices or transport agent seem complicated if can supply easy example i'll accept it. if have sink example runs on exchange 2010 please support careful explanation , examples/links. (step step if have to) other scripting languages accepted. possibly not looking postmark offer incoming mail service allows kind of thing. their api pretty , documented . understanding can set webhooks allow you're looking for. i hope use you.

python - Django / From redirect_to to RedirectView -

since know, can't use django.views.generic.simple import redirect_to in django 1.5. using kind of functions in our views.py: return redirect_to(request, '/auth/login/') i want migrate 1.4 1.5 couldn't figure out how use redirectview in views.py request , url argument. you can use redirect instead now can change redirect_to to return redirect('/auth/login')

javascript - Jasmine, require and play framework -

im stuck play framework , jasmine plugin made guardian newspaper, https://github.com/guardian/sbt-jasmine-plugin . i have gotten jasmine run play test, issues because of require. cases: trying load app or other modules want test in test.dependencies.js. results in error mismatched anonymous define() modules . js files wrapped in define. means crashes , test never run. trying call define around describe call on modules want test in current specc. results in error was: internalerror: couldn't read source file "./test.js: ./test.js (no such file or directory)". (rjs/r-2.0.1.js#2114). hard see want try load from. r-2.0.1.js creates error. im trying call require() on curent js file want test,file called test right now. results in error was: error: module name "test" has not been loaded yet context: _. not sure should do. im trying call require on current js file, in absolut path, want test. results in works. if write in function variables. can what

javascript - Syncrhonous Cross-Domain AJAX request -

suppose following directory structure: /web example.html example.js /example.json i open example.html browser , runs example.js, tries load data in example.json synchronously using following call: $.ajax({url: "file:///example.json", datatype: "json", async: false, success: function(data) { console.log(data) }, error: function(request, status, error) { console.log(request); console.log(status); console.log(error); } }); this results in error message "access restricted uri denied" , error code 1012. far, have taken @ access restricted uri denied“ code: ”1012 - cross domain ajax request , access restricted uri denied code: 1012 . first link suggested use jquery's getjson method, method works asynchronously. second link suggests sort of jsonp callback, haven't been able understand how these work. note problem goes away if move exampl

performance - Does it matter where I put the declaration of a variable? -

suppose have following 2 examples, there difference between putting variable declaration outside of loop vs inside loop, performance wise? note: new object being created inside loop. method 1: foreach (string name in namelist) { person person1 = new person(); person1.fullname = name; } method 2: person person1 = null; foreach (string name in namelist) { person1 = new person(); person1.fullname = name; } it's micro-optimization . no, performance wise, doesn't matter. difference in performance made irrelevant in practically non-trivial programs. , it's entirely possible optimizer convert less efficient form more efficient form (don't ask me which). i'd prefer first since it's slightly less code , limiting variable scope as possible considered practice. actually, more similar method 1, method 2 should this: person person1 = null; foreach (string name in namelist) { person1 = new person(); person1.fullname = name; } pe

Select Statement to loop through another javascript -

okay have select statement needs populate loop in javascript. have very basic knowledge of js. have basic coldfusion here using. problem 1 client side , other server-side. i need first select statement loop through cfloop inside javascript. need somehow change javascript loop (where says $(document).ready(function(){). don't know how. can help? <cfoutput> <script type='text/javascript' src='/jquery-1.8.2.js'></script> <script type="text/javascript"> function changehiddeninput (objdropdown) { var objhidden = document.getelementbyid("hiddeninput"); objhidden.value = objdropdown.value; } </script> </head> <body> <cfquery name="types" datasource="dsn"> select taking.*, type.* taking inner join type on taking.taking_typeid = type.type_id order type_id </cfquery> <form>how

cocoa - Implementing GameKit.framework on OSX, cannot authenticate localPlayer -

i'm attempting implement gamekit in osx game. unfortunately can't find information how this; tutorials seem ios (though the documentation states "game center available on ios , os x"). everything compiling fine; problem comes when try authenticate local user: [[gklocalplayer localplayer] setauthenticatehandler:^(id viewcontroller, nserror *error) { if(error) { dlog(@"error: %@",error);// returning error } else if(viewcontroller) { // do here?? } }]; i have 2 problems: first, handler gets error: error domain=gkerrordomain code=6 "the requested operation not completed because local player has not been authenticated." userinfo=0x10103bc70 {nslocalizeddescription=the requested operation not completed because local player has not been authenticated.} . second, don't know how present view controller. on iphone, code works fine: there's no error, , present viewcontrolle

java - Besides AsyncTask, is there anyway in Android to do something on the UI thread from another thread? -

because strange reasons, when use asynctask connect webpage, ui of app lags point of freezing while asynctask connecting webpage. i thought because connection takes quite long, @ least 4 seconds. i want able update textview after thread have finished, how do in android besides using asynctask? there few methods that: use threads or runnables use handlers, sending messages its use runonuithread method use method (this favorite) post. it's not necessary use context/activity instance for example, can create new handler() , when want run code in main thread do: public static handler interfacehandler = new handler(); ... minterfacehandler.post(new runnable() { @override public void run() { //your stuff } }); to complete information, views in android can make post(runnable) . method add runnable task do, reason recommendable not use views because app slow down. static handler perfect make work , easy implement

Links Won't Open When Using Multiple Tabs (Jquery Tabs) -

code multiple tabs on page (displaying these tabs , content dynamically): jquery('.tab-block li a').click(function() { var theitem = jquery(this); theitem.parent().parent().find("li").removeclass("active"); theitem.parent().addclass("active"); theitem.parent().parent().parent().parent().find(".tab-content > ul > li").removeclass("active"); theitem.parent().parent().parent().parent().find(".tab-content > ul > li").eq(theitem.parent().index()).addclass("active"); return false; }); code in html display tabs: <div class="tab-block"> <div class="tabs"> <ul> <li class="active"><a href="#">tab 1</a></li> <li><a href="#">tab 2</a></li> </ul> <div class="clear-float"></div> </div> <div class="tab-content"> <ul> <li class

javascript - THREE.js - Rotate the camera just like trackball controls -

i'm using trackball controls in scene , want implement function rotate camera way dragging mouse in canvas it. how can accomplish that? i've been looking code of trackball control module, can't find start. edit: i've been looking several pages, 3 documentation , whatnot, still can't reproduce trackball style rotation. i've been using quaternions can't reproduce behavior(or i'm missing something, probably). help? edit 2 : i'm looking way this: function rotatecam(angle) { // code } var angle = 0.01; //some value rotatecam(angle); $('#button').addeventlistener('mousedown', function() { rotatecam(angle); } ); where button html element representing button. i noticed trackball controls, apart of rotate via quaternion, zoom correct distances. tried read code, , got this: function rotate(l) { var vector = controls.target.clone(); var l = (new three.vector3()).subvectors(camera.position, vector).length(); v

javascript - Toggle the nearest content when click on anchor using jQuery -

i have content structure this: <a href="#" class="toggle_button">click me.</a> <p class="hidden_content">this content toggleable.</p> <a href="#" class="toggle_button">click me.</a> <p class="hidden_content">this different section.</p> <a href="#" class="toggle_button">click me.</a> <p class="hidden_content">this section different.</p> i have discovered how make work 1 section, how can make when click on toggle_button opens nearest hidden_content class. $('a.toggle_button').click(function() { $(this).next('p.hidden_content').toggle(); } http://api.jquery.com/next/

vb.net - Visual Studio 2012/Windows Phone 8 get results from Async Web Service -

so i'm working on windows phone 8 app (completely new windows phone 8 well) , i'm having trouble trying figure out how results asynchronous web service method right code tried fails , says "expression not produce value". here's code tried: 'get previous date dim pdate datetime pdate = datetime.today.adddays(-1) dim previousdate string = pdate.tostring("d") dim service new mobileservice.mobileservicesoapclient dim results new list(of string)() results.addrange(service.geterrortableasync(deviceidasstring, previousdate)) so geterrortable web service returns xml set of results , ios app can parse xml file create array of values (if exist) can't seem find consistent answer on how same windows phone/vb. guides or tutorials helpful since have web services return large array of objects , return single value. there should callback delegate function geterrortableasync , called geterrortablecomplete . add handler delegate. names might dif

windows - How to open regedit with C++ -

Image
this question has answer here: how launch windows' regedit path? 13 answers i'm looking way open registry editor , show specific key or value. example, if pass "hklm\\software\\skype\\installer" want such result: all suggestions except system() calls welcome. just call system . use raymond chen's words: it rather involved being on other side of airtight hatchway . relevant attack requires compromising machine point system call utterly irrelevant. in fact, attacker can change regedit can change your program well, add system call. (which won't, since pointless anyway)

c# - remove each listbox1 items after running the query? -

i have items inside listbox1 , want use each items run query, once query runned, want delete item inside listbox , use next item run query. example if item1 used delete item1 , use next item inside listbox run query.do items till no items left inside listbox1. foreach (string myitems in listbox1.items) { using (oraclecommand crtcommand = new oraclecommand(select regexp_replace(dbms_metadata.get_ddl('" + myitems + "'), conn1)) { string expectedresult = "y"; string dataresult = crtcommand.executescalar().tostring(); if (expectedresult == dataresult) { //do , remove item has been used run query. } else { } } } you cannot directly in foreach loop. give exception ' collection modified; enumeration operation may not execute ' if try inside foreach loop. rather after executing entire query can delete them all. listbox

Passing variables to new objects PHP OOP -

i wondering if way in passing variables different objects best way of doing things. have user class handles of information session. within user class variable (private) called isloggedon bool set @ false default. ideally need pass variable onto usermanage class can allow logged on user things such make new posts. here how i'm doing @ moment... $user = new user(); $usermanage = new usermanage($user->checkloggedon()); so can see have instance of user. within user class have method returns isloggedon variable (checkloggedon()) within user manage knows whether user logged on or not. please put mind @ ease , tell me whether best approach. thanks lot

c# - internal interface *less* accessible than an internal protected constructor? -

i have interface , abstract base class defined in same assembly: ifoo.cs: internal interface ifoo { ... } base.cs: public abstract class base { internal protected base(ifoo foo) { ... } } this generates following compiler error: cs0051: inconsistent accessibility: parameter type 'ifoo' less accessible method 'base.base(ifoo)' if make base class constructor internal-only, error goes away. since class abstract, maybe adding protected accessibility doesn't accomplish anything... still, don't understand error. msdn defines 'protected internal' "access limited current assembly or types derived containing class" how internal interface ifoo less accessible internal protected constructor? this msdn page defined 'protected internal' (emphasis original): the protected internal accessibility level means protected or internal, not protected , internal. in other words, protected internal

iphone - UIButton receiving touch events outside bounds when set as leftView of UITextField -

Image
this has been bit of head scratcher me. in app i'm building using uitextfield, , adding button leftview property. however, seems on ipad (both sim , on device), button receiving touches outside bounds. interfering ability of uitextfield become first responder when user touches placeholder text. seems when touching placeholder text, events being handled button instead of text field itself. strangely, appears happen on ipad; works expected on iphone. here simple code demonstrating problem: - (void)viewwilllayoutsubviews { [super viewwilllayoutsubviews]; uitextfield *textfield = [[uitextfield alloc] initwithframe:cgrectmake(10.0f, 10.0f, (self.view.frame.size.width - 20.0f), 35.0f)]; textfield.borderstyle = uitextborderstyleroundedrect; t

windows - Merge PDF with PDF::API2 under Perl and keeping the bookmarks -

i able utilize perl library pdf::api2 merge several pdfs according following code provided here: how use pdf::api2 merge several pdfs 1 perl? . #!/usr/bin/perl use strict; use warnings; use pdf::api2; # files merge @input_files = ( 'document1.pdf', 'document2.pdf', 'document3.pdf', ); $output_file = 'new.pdf'; # output file $output_pdf = pdf::api2->new(-file => $output_file); foreach $input_file (@input_files) { $input_pdf = pdf::api2->open($input_file); @numpages = (1..$input_pdf->pages()); foreach $numpage (@numpages) { # add page number $numpage $input_file end of # file $output_file $output_pdf->importpage($input_pdf,$numpage,0); } } $output_pdf->save(); but unfortunately bookmarks have been erased. does know solution using pdf::api2?

Amazon api book search - PHP -

i'm working on project school, , want search books related keywords (php, security, ...) on amazon. retrieve informations how many results there , link of search page,... i googled lot , found many libraries doesnt work anymore, or new ones require associate_tag , api_keys, subscribed , got api_keys, there's noway me associate_tag !! so i'm asking here, besides scrapping, there easy way explained above. thank in advance ps: feel free ask additionnal informations

php - Regex not getting whole link at special characters -

i using code: $string = preg_replace("~(?!(?:https?://(?:www\.)?|www\.)(?:youtube\.com)(?:https?://(?:www\.)?|www\.)[\w./=?#-]+~i", '<a href="$0">$0</a>', $string); so can turn link beneath clickable link. http://upload.wikimedia.org/wikipedia/commons/f/f2/bill_clinton%2c_yitzhak_rabin,%2c_yasser_arafat_at_the_white_house_1993-09-13.jpg this works part... makes link of http://upload.wikimedia.org/wikipedia/commons/f/f2/bill_clinton rest stays plain text. how can make work whole link? see comma too... how can make link? also i'm trying account punctuation @ end of url (so don't include it). <?php $string = "this works http://upload.wikimedia.org/wikipedia/commons/f/f2/bill_clinton%2c_yitzhak_rabin%2c_yasser_arafat_at_the_white_house_1993-09-13.jpg. 1 should fail http://www.youtube.com/v/adlskdfjasopie. although 1 should fail http://youtu.be/adlkajdaslk."; $string = preg_replace("~(?!(?:https?://

UIView not resizing correctly with UINavigationController in iOS 7 -

Image
i encountered strange behaviour of view in ios 6.1 app tried ran ios 7 beta 2 , on iphone. app has uinaviagationcontroller works fine if run in ios 6.1 simulator. however, xcode dp bottom part of view cut off. see picture. does know how fix this? drawing box see cut off on bottom (self.frame.size.height) of uiview managed navigation controller. thanks. try subtracting size of box amount of toolbar @ top. when using self.frame.size.height, use entire height location on view, when subtracting toolbar/navigation bar, raise enough fit entire box onto view //clearly not objc show how implement boxlocation @ (self.frame.size.height - (amount of toolbar/nav bar)) hope helps!

c++ - OpenCV Error: insufficient memory, in function call -

i have function looks this: void foo(){ mat mat(50000, 200, cv_32fc1); /* manipulation using mat */ } then after several loops (in each loop, call foo() once), gives error: opencv error: insufficient memory when allocating (about 1g) memory. in understanding, mat local , once foo() returns, automatically de-allocated, wondering why leaks. and leaks on data, not of them. here actual code: bool vidbow::readfeatpoints(int sidx, int eidx, cv::mat &keys, cv::mat &descs, cv::mat &codes, int &barrier) { // initialize buffers keys , descriptors int num = 50000; /// large number int ndims = 0; /// feature dimensions if (featname == "stip") ndims = 162; mat descsbuff(num, ndims, cv_32fc1); mat keysbuff(num, 3, cv_32fc1); mat codesbuff(num, 3000, cv_64fc1); // move overlapping codes previous window buffer int idxpre = -1; int numpre = keys.rows; int nummov = 0; /// number of

Capitalise every other letter in a string in Python? -

i've been trying define function capitalise every other letter , take spaces accout example: print function_name("hello world") should print "hello world" rather "hello world" i hope makes sense. appreciated. thanks, oli def foo(s): ret = "" = true # capitalize char in s: if i: ret += char.upper() else: ret += char.lower() if char != ' ': = not return ret >>> print foo("hello world") hello world'

symbols - Emacs. Abbreving "." to ending sentence -

i emacs newbie. trying expand character "." ". " (period 2 spaces in order more effective in ending sentence in emacs) abbrevs. in other words, when type "." followed space, emacs put ". ". i have put next code in abbrevs file, doesn't work. (text-mode-abbrev-table) "." 0 ". " anybody can me? i'm not sure why want this, here is: put in ~/.emacs : (defun electric-dot () (interactive) (if (and (looking-back "\\w") (not (looking-back "[0-9]"))) (progn (self-insert-command 1) (insert " ")) (self-insert-command 1))) (defvar electric-dot-on-p nil) (defun toggle-electric-dot () (interactive) (global-set-key "." (if (setq electric-dot-on-p (not electric-dot-on-p)) 'electric-dot 'self-insert-command))) afterwards, use m-x toggle-elect

weird php eregi behaviour in wamp and xampp -

this question has answer here: how can convert ereg expressions preg in php? 4 answers recently saw problem in simple code: $regexp = "^((http://)|(https://)|(mailto:)|(ftp://))?(([a-za-z0-9_.!~*'()-]|(%[0-9a-fa-f]{2})|[;&=+$,])+(:([a-za-z0-9_.!~*'()-]|(%[0-9a-fa-f]{2})|[;:&=+$,])+){0}@){0}((((((2(([0-4][0-9])|(5[0-5])))|([01]?[0-9]?[0-9]))\.){3}((2(([0-4][0-9])|(5[0-5])))|([01]?[0-9]?[0-9]))))|(([a-za-z0-9](([a-za-z0-9-]{0,62})[a-za-z0-9])?\.)*([a-za-z](([a-za-z0-9-]*)[a-za-z0-9])?)))?(:(([0-5]?[0-9]{1,4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5])))?(/((;)?([a-za-z0-9_.!~*'()-]|(%[0-9a-fa-f]{2})|[:@&=+$,])+(/)?)*)?(\?([;/?:@&=+$,]|[a-za-z0-9_.!~*'()-]|(%[0-9a-fa-f]{2}))*)?(#([;/?:@&=+$,]|[a-za-z0-9_.!~*'()-]|(%[0-9a-fa-f]{2}))*)?$"; $urladdr = '89.221.92.122/api/xml'; $result = eregi($r

regex - regular expression to match repeated characters? -

i'm looking perl regular expression match strings made of same letters. it should match aa , aaa , aaaa , aaaaa , on, not aabb , abba , aaab , aaaabaa , on. i know can use \1 refer first character /(.)\1/ , match aabb . advice? this seems work me: /^(.)\1*$/ the ^ character matches beginning of string, , $ matches end. the whole expression can translated into: "at beginning of string, match character, followed number of same character, followed end of string.

java - Override properties set in JAR file with local properties -

i have spring 3.0 mvc project uses jar file different project dependency. jar file has "auth.properties" file in it's resource , has string in this. ex: packages.redirecturls.gotourl = 'http://myurl.com'; now, referring string in jar file in controller using: @value("${packages.redirecturls.gotourl}") i have local "auth.properties" file consists of same string different value in it. ex: packages.redirecturls.gotourl = 'http://newurl.com'; however, java code not able read new configuration , loads jar file. there way override jar file setting new setting? thanks,

Kendo-UI Chart error -

i trying show kendoui chart inside div , looks log says: invalid negative value attribute width="-10px" this code: <div id="chart"></div> this javascript: $("#chart").kendochart({ theme: "metro", legend: { position: "right", labels: { font: "12px arial", color: "white" }, }, chartarea: { background: "", }, datasource: data, series: [ { type: "pie", field: "itemtotal", categoryfield: "itemnameandtotal", explodefield: "exploded" } ], tooltip: { visible: true, template: "${ category }"

jquery - Why is the class of my dynamically created element not recognised? -

this question has answer here: event binding on dynamically created elements? 18 answers i have textbox. if selected , hit tab key, new line open. works fine far. however, same action doesn't work in dynamically created textbox. if has same class original textbox called on. tried find explanation on internet, couldn't get/understand right answer. please me? http://jsfiddle.net/rzclm/1/ $('.list').keydown(function(key){ if(key.which === 9) { $('.ingredients_list').append('<li><input class="list" type="text"/><i><img class="remove" src="images/remove.svg"></i></li>'); } }); use $(document).on target dynamically created elements: $(document).on('keydown', '.list', function(key){ if(key.which === 9) { $(

django - AttributeError: 'tuple' object has no attribute 'startswith' -

completely new coding, sorry simple questions. i'm getting attribute error when running python manage.py collectstatic . i'm editing settings.py . have django 1.5.1 , python 2.7.5. appreciated , in advance (again). file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/posixpath.py", line 61, in isabs return s.startswith('/') attributeerror: 'tuple' object has no attribute 'startswith' now, of course i've never messed posixpath.py . here's contents of settings.py (minus db info , such): media_root = "os.path.join(os.path.dirname(os.path.dirname(__file___))", "static", "media" media_url = '/media/' static_root = "os.path.join(os.path.dirname(os.path.dirname(__file__))", "static", "static-only" static_url = '/static/' staticfiles_dirs = ( "os.path.join(os.path.dirname(os.path.dirname(__file__))", "static"