Posts

Showing posts from January, 2011

c++ - One class with a vector data member -

i define class vector data member. class looks follows class a{ ... private: std::vector<int> v1; ... }; if use operator new allocate memory class a, program ok. however, if memory pre-allocated memory , cast pointer type a*, program crash. a* = new a; a* b = (a*)pre_allocated_memory_pointer. i need 1 vector variable size , hope memory 1 pre-allocated memory. have idea problem? an std::vector object requires initialization, cannot allocate memory , pretend you've got vector . if need control memory solution defining operator::new class. struct myclass { std::vector<int> x; ... other stuff ... void *operator new(size_t sz) { ... somewhere sz bytes , return pointer them ... } void operator delete(void *p) { ... memory free ... } }; another option instead specify allocate object using placement new: struct myclass { std::vector<int> x; ... other stuff ... }; void foo() { void *...

multithreading - Verifying thread safety with JUnit -

i test if code thread safe calling multiple threads @ same time different parameters. below example of how code want test looks like public void writestringtofile(string filename, string tobewritten) { //some implementation junit should not care. } in above code want verify if code thread safe if invoked different file names multiple threads @ same time. how should design junit easy understand , maintain? if changed code public void writestringtooutputstream(outputstream out, string tobewritten) (or made actual implementation, , original method thin wrapper), pass filteroutputstream looks out concurrent writes, possibly blocking while other potential concurrent writes can try execute. but checks writes aren't concurrent, not class isn't thread-safe. if detect concurrent writes, read data , make sure it's valid.

wpf - UserControl enum DependencyProperty not binding -

i created usercontrol contains 3 dependencyproperties. 2 working fine, there 1 gives me real headache. have enum (outside usercontrol class same namespace): public enum recordingtype { norecording, continuesrecording, eventrecording } i created dependencyproperty follows: public static dependencyproperty selectedrecordingtypeproperty = dependencyproperty.register("selectedrecordingtype", typeof(recordingtype), typeof(schedulercontrol), new frameworkpropertymetadata((recordingtype)recordingtype.norecording, frameworkpropertymetadataoptions.bindstwowaybydefault)); public recordingtype selectedrecordingtype { { return (recordingtype)getvalue(selectedrecordingtypeproperty); } set { setvalue(selectedrecordingtypeproperty, value); } } and i'm using in xaml this: <usercontrols:schedulercontrol grid.row="1" ...

asp.net - how to make virtual directory to root -

i have project in in number of pages page redirecting code written like response.redirect(~/pagename); now @ hosting server, working fine root directory but on testing server, have created virtual directory such site1 now have map like response.redirect(~/site1/pagename); then page being open is there way through webcofig, or global.asax or other way can tell site treat ~/(root) ~/site thanks in iis right click on 'sites' , select 'add web site'. set path site1 root of new web site. set bindings port 81 can access @ same time default site.

ember.js - Passing in a Handlebars template as a variable to a Handlebars template -

i have situation need render handlebars template created user. i've been able hack 1 solution: using view compile user-generated template + context html, making resulting string available "final" template. i'd prefer able expose template variable "final" template, , have final template evaluate if actual hbs code; if use triple braces {{{ , handlebars variables (of course) escaped. is there way this? helper perhaps, first compiles variable context, outputs string? problem here ember.handlebars wired work ember; need final, unbound html. one possible approach use view dedicated rendering user defined template. setting template variable , re-rendering it, template change dynamically. example, http://emberjs.jsbin.com/yexizoyi/1/edit hbs <script type="text/x-handlebars"> <h2> welcome ember.js</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name=...

python - How to check a member variable with py.test skipif? -

in setup function in testcase set member variable is_type true or false. have few tests in class shouldn't run if value false. don't know how skipif functionality. @py.test.mark.skipif( not ???.is_type ) def test_method(self): ... self doesn't work ??? since it's not in object yet. how can refer is_type variable? more complete example: class dbtest(unittest.testcase): def setup(self): self.is_dynamo = os.environ.get( 'test_db', '' ) == 'dynamo' def test_account_ts(self): if not self.is_dynamo: return ... how can transform if not self.is_dynamo py.test skipif condition instead? as mention, can't refer instance in skipif marker, since instance doesn't exist yet. i keep simple , like: @pytest.mark.skipif(os.environ.get('test_db') != 'dynamo') def test_dynamo(): db = mydatabasewithdynamo(is_dynamo=true) # assertion or other. you ca...

android - how to display the recent call logs -

i new in android programming.i want data of recent call logs not whole history write code .it displays records upto newest call record . please me. please tell me use or how can recent call data code public class mainactivity extends activity { textview call; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); call =(textview) findviewbyid(r.id.tvcall); calldetails(); } private void calldetails() { stringbuffer sb = new stringbuffer(); cursor managedcursor =managedquery(calllog.calls.content_uri, null, null, null, null); int number = managedcursor.getcolumnindex(calllog.calls.number); int name = managedcursor.getcolumnindex(calllog.calls.cached_name); int type = managedcursor.getcolumnindex(calllog.calls.type); int date =managedcursor.getcolumnindex(calllog.calls.date); int duration ...

inputstream - Android record stream can't stop -

i want record streaming radio now code press.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { string filename = environment.getexternalstoragedirectory().getabsolutepath(); filename += "/music.mp3"; outputsource= new file(filename); bytesread = -1; url url; try { url = new url("** url **"); inputstream = url.openstream(); log.d(log_tag, "url.openstream()"); fileoutputstream = new fileoutputstream(outputsource); log.d(log_tag, "fileoutputstream: " + outputsource); while ((c = inputstream.read()) != -1) { fileoutputstream.write(c); bytesread++; } } catch (malformedurlexception e) { // todo auto-gener...

c++ - Given very long binary, convert it to decimal -

first, part of hw. second, part of it, appreciate hints here. i've implemented kind of bigint class, stores numbers sequences of zeros , ones - stores decimal binary. my class can add numbers , multiply them. ok, when multiply 2 large numbers, huge number. my question - given really long binary number, how convert decimal? i've found dividing 10, i'm not sure, if that's case... or is, , have implement binary dividing? thanks... binary means base 2 if have example 10100 , need base 10 you apply following pattern, going last element first (right left): 2^0*0 + 2^1*0 + 2^2*1 + 2^3*0 + 2^4*1 = 20 raise 2 power a starting 0 length_of_binary_num-1 , multiply power binary digit string(right-to-left) or have aditional method on convert binary decimal also recommend using string binary since binary digits tend more strings integers

c# - ASP UpdatePanel doesn't work when used in ContentPage -

my code works fine when used in normal webform. when use in webform using masterpages, doesn't work. page header : ~/manager/basemanager.master and nested master pages : base.master > pages.master > basemanager.master asp <asp:scriptmanager id="scriptmanager1" runat="server"></asp:scriptmanager> <asp:updatepanel id="updatepanel1" runat="server" updatemode="conditional"> <triggers> <asp:asyncpostbacktrigger eventname="click" controlid="btnupdateeditpage" /> </triggers> <contenttemplate> <asp:label id="lbltest" runat="server" text="label"></asp:label> </contenttemplate> </asp:updatepanel> <asp:button id="btnupdateeditpage" cssclass="btnupdateeditpage" runat="server" text="button" onclick...

display fields if not empty in PHP/YII -

i used code groovy ... found 'feature' (no idea called it) fun n nice (i heard implemented on c# too). for example ... want display person neighbour name i type println person?.neigbour?.name ; it means if neighbour empty / blank .. didn't display . how in php 5/yii? example: instead of typing long codes '/> would better type '/> in first place think no yii issue, php. assuming, use yii nice models, there go sth this: if($person && $person->neighbour && !empty($person->neighbour->name)) { echo $person->neighbour->name; } a shortcut may (not nice): echo $person ? ($person->neighbour ? ($person->neighbour->name ? $person->neighbour->name : "" ) : "" ) : "";

html - Add property with - in name -

in mvc using html.textboxfor() control i have input type control below. <input id="phonenumber" type="text" class="phonenumber form-control" value="@actorphone.phonenumber" data-phonetype ="@actorphone.phonetypetd" data-actorid ="@model.actorid" maxlength="30"/> i want change intput control mvc @html.textboxfor(m=>m.phonenumber,new {@class = "phonenumber", maxlength = "30"}) how can add data-phonetype , data-actorid properties html control, - not allowed in properties of html attribute . use underscore _ the razor engine smart enough render underscore within property name corresponding dash sign, resulting in desired html5-like attributes example: @html.textboxfor(m=>m.phonenumber, new {@class = "phonenumber", maxlength = "30", data_phonetype = your_value_here, data-actorid=your_value_here }) and should result in ...

Google Analytics event tracking with PHP in html_output -

i'm getting category database using php , want use inside google analytics event tracking code. problem events not being recorded in google analytics. here code snippets project: 1) $docs = array(); while ($row = mysql_fetch_assoc($result)) { $doc = array(); $doc['my_tel'] = $row['my_tel']; $doc['my_category'] = $row['my_category']; $docs[] = $doc; } mysql_free_result($result); 2) <?php $html_output = ''; foreach ($docs &$d) { $html_output .= '<div>' . '<a href="tel:' . $d['my_tel'] . '" onclick="_gaq.push([\'_trackevent\', ' . $d['my_category'] . ', \'event action\', \'event label\']);"><img src="call.png" width="65px" height="35px" border="0"></a>' . '</div>'; } echo $html_output; ?> if have @ console...

jquery - $(window).scroll() Loop, due to no variable -

i have bit of problem; have code: $(window).scroll(function(){ if ($(document).scrolltop() >= $('.services-container').offset().top-80) { alert("test"); } }); now works ok, except need run if statement once, tried variables cannot them not re-set previous state due window scroll loop... help? you can try flag: var flag = true; $(window).scroll(function() { if ($(document).scrolltop() >= $('.services-container').offset().top-80 && flag) { alert("test"); flag = false; } }); demo fiddle

java - Highstock/Highchart OHCL not showing? -

hey guys having trouble loading data highstock charts. i tired display chart highstock my data.json [{ "date":1395651841, "price":11, "amount":12, "tid":33170585, "price_currency":"usd", "item":"none", "trade_type":"bid" }, { "date":1395651836, "price":4, "amount":3, "tid":33170584, "price_currency":"usd", "item":"none", "trade_type":"ask"} ] and my html <script type="text/javascript"> $(function() { $.getjson('data.json', function(data) { // create chart $('#container').highcharts('stockchart', { rangeselector : { inputenabled: $('#container').width() > 480, selected : 1 ...

python - Elementwise logical comparison of numpy arrays -

i have 2 numpy arrays of same shape. elements in arrays random integers [0,n]. need check (if any) of elements in same position in arrays equal. the output need positions of same elements. mock code: a=np.array([0,1]) b=np.array([1,0]) c=np.array([1,1]) np.any_elemenwise(a,b) np.any_elemenwise(a,c) np.any_elemenwise(a,a) desired output: [] [1] [0,1] i can write loop going through of elements 1 one, assume desired output can achieved faster. edit:the question changed. you want evaluate np.where(v1==v2)[0]

fold - Where's foldl1 and foldr1 in Racket? -

racket has foldl , foldr , require initial value. haskell in addition has foldl1 , foldr1 , instead of applying function on initial value , first element, applies first , second element. implemented them as: (define (foldl1 f xs) (foldl f (first xs) (rest xs))) is there better way? there better way, (require srfi/1) , use reduce , reduce-right . :-d

javascript - JS Form validation is not working For html form -

i have simple html form. form follows- <table> <form method="post" action="insert.php" name="idea_1" id="idea_1" onsubmit="return idea_1_check();" > <input type="hidden" name="type" value="idea" /> <tr><td></td><td><br><h3 style="color:#990066; font-weight:bold;">first member (team leader)</h3><br></td></tr> <tr><td></td><td><input type="text" name="stu_name_1" value="" placeholder="your full name"></td></tr> <input type="text" name="school_name_1" value="" placeholder="your school name"></td></tr> <tr><td></td><td><input type="text" name="stu_id_1" value="" placeholder="your student i...

php - Problems substituting table name into variable -

i'm splitting character $rg , matching table name using strstr string function. stored table name in array. string function returns cs_branch pass sql query. not matching table name in present in database..... <?php $rg="175cs11011"; $arr=preg_replace('/[^a-za-z]/','',$rg); $br=array("cs_branch","ce_branch"); mysql_connect("localhost","root","6semcs") or die(mysql_error()); mysql_select_db("gptistu_progress") or die(mysql_error()); for($i=0;$i<2;$i++) { $ma=strstr($br[$i],$arr); echo $ma; $data ="select * `$ma`"; } mysql_query($data) or die(mysql_error()); ?> try change for($i=0;$i<2;$i++) { $ma=strstr($br[$i],$arr); echo $ma; $data ="select * `$ma`"; } with foreach($br $tablename) { $data ="select * `" . $tablename . "`"; } p.s. mysql_query() must in cycle too.

c - Put variables in a buffer in different parts of the program -

i'm working on c project requires me send variables on file through socket connection (on same machine - through "localhost"). therefore, in order send variables file file b, put such variables in buffer (defined char 1d array) , send whole buffer different variables contained in it. so, use sprintf(buffer, "%f\n %f\n", variable1, variable2) put variables file a. file b read buffer, , associate variables in buffer variables of it's own, do: sscanf(buffer, "%f\n %f\n, &variable1, &variable2); variable1 , variable2 have been defined in file b. however, i'm wondering if it's possible put variables in buffer in file through different instances in program. if so, everytime new variable put in buffer, file b able access variables in same order they're put in file a? example, if variable1 , variabe2 put in buffer in point a, , varibale 3 put in buffer in point b, file b able access variables in order? finally, if variable of same na...

c# - Report Viewer Issue(.rdlc) in VS 2010 -

i creating new rdlc report file in vs 2010 in web application. project consists existing rdlc files build in vs 2008. when run project , view report following error: an error occurred during local report processing. definition of report 'main report' invalid. report definition not valid. details: report definition has invalid target namespace ' http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition ' cannot upgraded. i had same error , after checking following link : https://cmatskas.com/resolving-rdlc-error-the-report-definition-is-not-valid-in-visual-studio-2012/ i found out default referenced microsoft.reportviewer.webforms.dll version vs 2008 version : 9.0.0 searched dll , found in : c:\program files (x86)\microsoft visual studio 12.0\reportviewer\microsoft.reportviewer.webforms.dll after referencing , worked

apk - How to generate java/android signature block file (.RSA) with php (phpseclib) -

i’m trying sign android .apk file on server php. for need generate files contained in meta-inf directory inside .apk file(which zip file). creating .mf , .sf files in php simple. however, i'm struggling .rsa file. unfortunately, don’t know cryptography , don’t understand basic terms. know php basics, i’m far experienced , have no overview of necessary libraries/functions. therefore after many hours of research, still wasn’t able create useful. from understand, .rsa file should contain: digital signature of .sf file certificate signers public key this file should pkcs7 formatted. i trying use phpseclib this. able create private/public key/certificate examples on internet, i’m absolutely not able put form .rsa file. stackoverflow has been great source of information , found of answers questions here. however, i’m stuck. could guys please give me php example code(ideally)? or pseudocode/algorithm… possible accomplish phpseclib/php? there “bit shifting” necessary...

spring - Issue configuring JBoss EAP 6.1 with hibernate 3.6 -

i'm trying deploy ear file in local server seems it's still trying use hibernate 4 (the default option, guess). what have done: i've added hibernate 3 module in $jboss_home$\modules\org.hibernate\3 module.xml file: <module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3"> <resources> <resource-root path="hibernate3.jar"/> <resource-root path="commons-collections-3.1.jar"/> <resource-root path="jta-1.1.jar"/> <resource-root path="javassist-3.12.0.ga.jar"/> <resource-root path="antlr-2.7.6.jar"/> <resource-root path="slf4j-api-1.6.1.jar"/> <resource-root path="dom4j-1.6.1.jar"/> <!-- insert other hibernate 3 jars used here --> </resources> <dependencies> <module name="org.jboss.as.jpa.h...

ios - Xcode using wrong localization -

i have 2 localizations in project: base (which in english) , swedish. when set phone swedish works, , when set english works. when set language, example german, uses swedish translations instead of base. ideas why? i found answer. in phones settings, don't set current language, set language priorities. if you've had swedish , switches language, swedish second priority , english lower.

gulp: translations (gettext) only takes last .po file -

i'm using gulp , gettext, works except when have multiple .po files. gulp.task('translations', function () { return gulp.src('app/po/*.po') .pipe($.gettext.compile()) .pipe($.rename('translations.js')) .pipe(gulp.dest(dest)); }); i have 3 .po files: lang1.po , lang2.po , lang3.po , , lang3.po in translations.js . guess task overwriting things. suggestions how can cat translations.js ? what doing here is: step 1: compile lang1.po, compile lang2.po, compile lang3.po step 2: rename lang1.po translations.js, rename lang2.po translations.js, rename lang3.po translations.js get idea? you want concat instead (using gulp-concat ). gulp.task('translations', function () { return gulp.src('app/po/*.po') .pipe($.gettext.compile()) .pipe(concat('translations.js'))) .pipe(gulp.dest(dest)); }); hope helps.

html - How to stop overflowing text and make it several lines if needed? -

the filters at http://www.carsguide.com.au/news-reviews-search/?keywords=bmw&search-option=http%3a%2f%2fwww.carsguide.com.au%2fnews-reviews-search%2f are overflowing in left in chrome , ff. rather putting fixed width text there, there better way? how stop overflowing text , make several lines if needed? if goes several lines, number beside vertically centered....? to stop overflowing text, add word-wrap: break-word; on <a> tag

crystal reports - Does JasperReports have distinctcount(col1,col2) option? -

we have crystal report built us. need understand , make crystal jasperreports . using ireport 4.5.1 designing reports. i want know crystal provides distinctcount(col1,col2) fields , similar option available jasperreports ? please let me know if not clear question

c# - Get and Post methods not working in Web API Controller -

i have post method in controller works fine. want include 1 more method in same controller list of records. unable records. if write method in different controller works fine when include same method in existing controller gives error 'failed load resource: server responded status of 405 (method not allowed)'. here code of controller: using myapp.entity.models; using newtonsoft.json.linq; namespace myapp.server.controllers { [routeprefix("api/dashboard")] public class memberscontroller : baseappcontroller { public memberscontroller() { } public memberscontroller(httpcontext current) { httpcontext.current = current; } [allowanonymous] public string postmemberdetails(jobject memberdata) { //my code here } [allowanonymous] public list<myapp.entity.models.registeredmembers> get(bool isregistered) { //my code here }...

Navigating an HTML tree in Python -

<td id="aisd_calendar-2014-04-28-0" class="single-day future" colspan="1" rowspan="1" date="**2014-04-28**" > <div class="inner"> <div class="item"> <div class="view-item view-item-aisd_calendar"> <div class="calendar monthview"> <div class="calendar.4168.field_date.8.0 contents"> <a href="/event/2013/regular-board-meeting">**regular board meeting**</a> <span class="date-display-single">7:00 pm</span> </div> <div class="cutoff">&nbsp;</div> </div> </div> </div> </div> </td> hi! have above html code. extract "date" tag ( 2014-04-28 ) , "a href" tag ( regular board meeting ) above. how can using python? can done using beautiful soup?...

javascript - Maintain previous Page values and selected controls states on Browser back button click -

i'have developed asp.net project in .net 4.0, fine, except when user clicks browser button, old page loosing control's selected states (eg checkboxlist, dropdownlist etc.) and values entered in textboxes . "i tried resolved putting session variables, before redirect i'm saving in session and, when user goes previous page, i'm validating session state , rebinding everything. seems costly operations." is there other/near-around solution. (please note i'm using ajax componets , update panels.) thanks in advance... you can save form state using cookies , reading them again after detecting history.back or alternatively please check jquery plugin http://tkyk.github.io/jquery-history-plugin/#documentation

python - ( How ) does scipy.integrate.odeint accelerate function evaluation? -

typically pure python is ~50x slower native code (c, fortran) if consist of tight loop simple aritmetics. when use scipy.odeint described example in tutorial write functions integrate in pure python this: def f(y, t): si = y[0] zi = y[1] ri = y[2] # model equations (see munz et al. 2009) f0 = p - b*si*zi - d*si f1 = b*si*zi + g*ri - a*si*zi f2 = d*si + a*si*zi - g*ri return [f0, f1, f2] this function has evaluated manytimes, expect make huge performace bottleneck, considering odeint integrator made in fortran/odpack does use convert function f(y,t) python native code? (like f2py, scipy.weave, cython ...) far know, odeint not need c/c++ or fortran compiler, , not increase initialization time of python script, f2py , scipy.weave not used. i'm asking question, because, maybe, idea use same approach scipy.integrate.odeint use acceleration of tight loops in own code. using odeint more convenient using f2py or scipy...

python - Kivy. How to select different mouse devices. How to create an event 'on move' -

most of previous experience in embedded guess lacking in oop. so far here dry run using kivy's framework : from kivy.app import app kivy.uix.widget import widget kivy.core.window import window class mywidget(widget): def my_on_motion (self, something_missing_here, my_motion_event): print my_motion_event.pos , my_motion_event.device pass window.bind(on_motion=my_on_motion) class myapp(app): def build(self): return mywidget() if __name__ == '__main__': myapp().run() i wanted build puzzle mechanics "hover on select" sort of mechanics using multiple plug , play 'standalone touchpads'. effectively have 2 questions: -how differentiate between device id's? (in case 'device' 'mouse' irrespective of plugging multiple mouses) -how motion event trigger on movement of mouse , not when touch true?

jquery - Ajax refreshing page -

on change of dropdown im reading drop down value , making on ajax call fetch data.i want refresh same page. tried this $('#status').change(function(){ var status = $('#status').val(); $.ajax({ url : "partners.action", data: {status : status}, success : function(data) { alert(status); $("#status").html(data); } }); }); but not refreshing solution 1: you can page refresh using method proposed @neel. in case want refresh whole page , data back, first need store in database. also, filling data in same control on observing .change event. replace $("#status").html(data); $('#yourhtmlcontrol').html(data); alternate method: way of doing use of querystring. can this. success : function(data) { alert(status); $("#status").html(data); window.location="currentpageurl.aspx?data="+data; } later can read querystring...

ruby on rails - Heroku toolbelt returning error after install on SUSE 13.1, don't understand the message? -

newbie question: new linux , trying install heroku toolblt on open suse 13.1 new install without heroku gem beeing abord. heroku first not recognized @ command line, after reboot of system heroku recognized not start, returns error message (see below). purpose learn work ruby , rails, have installed: ruby 2.0.0p247 (2013-06-27) [x86_64-linux], rails 3.2.13, gems 2.0.3, git version 1.8.4.5 i have installed standalone version of heroku toolbelt, , have followed instruction http://blog.cornelius-schumacher.de/2013/04/how-to-deploy-rails-app-to-heroku-on.html , added symbolic link local bin directory. first suspected may problem, problems heroku toolbelt , suggested solution in place in installation. as call on heroku, example in: heroku login the following returned: /usr/lib64/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- netrc (loaderror) /usr/lib64/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `requir...

selection - Can't manipulate inputs in EditForm.aspx with jQuery -

i try manipulated “editform.aspx” of list in site collection (sharepoint 2013). want input fields hidden based on users permission level. realize this, added editor webpart standard form of editform.aspx following code: <script src="https://test-teamshare.zeiss.org/minimal/05011/libs/jquery-latest.js"></script> <script src="https://test-teamshare.zeiss.org/minimal/05011/libs/jquery.spservices-2013.01.js"></script> <script type="text/javascript"> _spbodyonloadfunctionnames.push("hideinputfields"); function hideinputfields() { $().spservices({ operation: "getrolesandpermissionsforcurrentuser", async: false, completefunc: function(xdata, status) { var userperm = $(xdata.responsexml).spfilternode("permissions").attr("value"); var userrole = $(xdata.responsexml).spfilternode("role").attr("name"); ...

python - running the program after it terminates using cron -

i need set program in cron set in such way restarts everytime program terminated why want job? the program extracting information website using web scrapping , terminates when reaches point information up-to- date part of python code sql = """select short_link properties short_link=%s""" rows = cursor.execute(sql,(link_result)) print rows if rows>=1: print "already present" sys.exit() else: query="""insert properties (published_date, title,price,bedroom,agency_fee, bathroom, size,prop_ref,furnished_status,rent_payment,building_info,amenities,trade_name,licence, rera_id,phone_info,short_link) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)""" cursor.execute(query,(date_result, title_result, price_result, bedroom_result, agencyfee_result, bathroom_result, size_result, propertyref_result, furnish...

maven - How to exclude {test} scoped dependencies from build? -

i have java project build maven has dependencies. 1 of such dependencies project (i have eclipse workspace in mind) , in test scope. <dependency> <groupid>my.group.id</groupid> <artifactid>artifactid</artifactid> <version>1.0</version> <scope>test</scope> </dependency> i build projects using following command inside project root dir mvn clean package -dmaven.test.skip=true what expected happen maven build project leaving test dependencies behind. unresolved dependency exception thrown (unresolved test scoped dependency). ran build command -x option, spoted following report in project build plan: [debug] dependencies (collect): [] [debug] dependencies (resolve): [compile, runtime, test] [debug] repositories (dependencies): [central (http://repo.maven.apache.org/maven2, releases)] [debug] repositories (plugins) : [central (http://repo.maven.apache.org/maven2, releases)...

node.js - Installing a another Sails.js version locally -

i've installed sails.js version 0.9.13 globally on mac runs fine, i'm trying fiddle 0.10.0-rc4 locally in folder. running sudo npm install sails@beta seems work fine; node_modules/package.json says "version": "0.10.0-rc4" but when run sails new testproject in folder, generated testproject/package.json says "sails": "0.9.13" . i know change testproject/package.json "version": "0.10.0-rc4" , npm install doesn't work. what doing wrong? how fix this? basically, can run ./node_modules/sails/bin/sails.js new testproject instead of sails new testproject once have installed rc4 in 'parent' folder.

java - Why do I have to use setvisible() on my JFrame when I change components? -

so sake of simplicity set little test code figure out problem. have jframe , added 'this' (i extended main class jcomponent save time). component fills in red background. have sleep 2 seconds , type this. f.remove(this); thing t = new thing(); f.add(t); f.setvisible(true); f being jframe object , 'thing' class extending jcomponent paints blue background.. when comment out setvisible() no longer changes blue.. i've tried using t.setvisible(true) seems have make frame visible again, not component does know why have call that... or if there way change components within single frame? "basically have jframe , added 'this' (i extended main class jcomponent save time). component fills in red background. have sleep 2 seconds , type this." don't "sleep" program. instead use java.swing.timer perform repeated tasks on gui or animation. see more @ how use swing timers . can see bunch of timer examples here , h...

c# - error CS0234: assembly or namespace not found while publishing -

Image
i faced strange issue today, please see error below: error cs0234: type or namespace name not exist in namespace many developers facing issue on compile time mode, while compiling code not getting error while publishing code getting it. what doing before: adding reference using solution: using project file reference add reference in main project. what did fix it adding reference using browse: pointed direct dll of second project release folder any 1 guide me why causing issue? still right approach adapted fix it? if use csproj file reference reference second project in main project still need configurations make work? any appreciated. thanks in advance.

SQL ALTER DROP query not working -

i learning sql online w3school.com . for droping column alter table table_name drop column column_name command given in sql alter page i tried in try yourself section provided w3school. it's not working i used alter table customers drop column city; i try query on compile online/sql . again it's not working. so, can 1 explain me wrong. did notice says in brackets? to delete column in table, use following syntax (notice database systems don't allow deleting column) see answers these questions: websql drop column javascript how delete or add column in sqlite? w3schools uses websql. try sqlfiddle instead.

Jquery won't count checkbox when checked first time -

i have problem jquery script, has count checked boxes, won't count on first time clicked, have check-uncheck-check again in order count. counts correctly in firefox` $("#collapseone input[type=checkbox]").click(function( event ) { var max = 3; var checkboxes = $('#collapseone input[type="checkbox"]'); checkboxes.change(function(){ var current = checkboxes.filter(':checked').length; $( "#col1" ).text(current); checkboxes.filter(':not(:checked)').prop('disabled', current >= max); }); http://jsfiddle.net/nm8t9/ there no need have click handler var max = 3; var checkboxes = $("#collapseone input[type=checkbox]"); checkboxes.change(function(){ var current = checkboxes.filter(':checked').length; $( "#col1" ).text(current) ; checkboxes.filter(':not(:checked)').prop('disabled', current >= max); }); demo: fiddle...

backwards compatibility - A program made with Java 8 can be run on Java 7? -

i little confused. oracle says java 8 highly compatible java 7 (backward). but, possibilities exist java 8 program can run on java 7 (se/ee)? if point 1 true, java 8 applications deployed , executed on java 7 server support? example, tomcat 8 or wildfly? in general, no. the backwards compatibility means can run java 7 program on java 8 runtime, not other way around. there several reasons that: bytecode versioned , jvm checks if supports version finds in .class files. some language constructs cannot expressed in previous versions of bytecode. there new classes , methods in newer jre's won't work older ones. if really, want (tip: don't), can force compiler treat source 1 version of java , emit bytecode another, using this: javac -source 1.8 -target 1.7 myclass.java ( the same maven ), , compile against jdk7, in practice more not work work. i recommend don't. edit : jdk 8 apparently doesn't support exact combination, won't work....

How to append elements at the end of ArrayList in Java? -

i wondering, how append element end of arraylist in java? here code have far: public class stack { private arraylist<string> stringlist = new arraylist<string>(); randomstringgenerator rsg = new randomstringgenerator(); private void push(){ string random = rsg.randomstringgenerator(); arraylist.add(random); } } "randomstringgenerator" method generates random string. i want append random string @ end of arraylist, stack (hence name "push"). thank time! here syntax, along other methods might find useful: //add end of list stringlist.add(random); //add beginning of list stringlist.add(0, random); //replace element @ index 4 random stringlist.set(4, random); //remove element @ index 5 stringlist.remove(5); //remove elements list stringlist.clear();

Bash string change part of words -

i need change string before printing in bash . did: ${retezec//./d} now need change 1 more thing, - _ . no idea how add there? in same step $`{retezec//./d;//-/_} , need 1 exeption 1 - ? it's not possible nest parameter expansion, need 2 expressions: foo=${retezec//./d} echo "${foo//-/_}" you can, however, use external tool recommend stick native shell solution above. $ echo "foo.-bar" | tr '.-' 'd_' food-bar

javascript - Set style for only the first element using JQuery -

ok have set styles of section locked using : $("section").attr("class", "xxx locked"); but want first section in page have different style : $("section").first().attr("class", "xxx"); but doesn't work... this first element generated dynamically document.getbyid(smtgn).value won't work use :first selector.. $("section:first").attr("class", "xxx");

Set AVC/H.264 profile when encoding video in Android using MediaCodec API -

android provides way query supported encoding profiles. when setting encoder cannot find way specify desired profile used. finding supported profile/level pairs using mediacodec api in android can call getcodecinfo() once have chosen encoder component. returns mediacodecinfo object provides details codec component being used. getcapabilitiesfortype() returns codeccapabilities object, detailing codec capable of. contains array of codecprofilelevel s detail supported profiles , levels supported. trying set profile i can't see field set profile mediecodec or mediaformat . there key_aac_profile mediaformat , in reference explicitly states aac audio only. in mediacodec there way pass bundle of parameters codec using setparameters() . looks has no generic documentation, , parameters accepted different between codecs (different devices). background profiles specify set of encoding features use. simple profiles less computationally intense, sacrifice quality gi...

gcc - UBuntu 12.04 LTS - warnings treated as errors when building Thrift 0.9.1 -

i use ubuntu 12.04 lts , gcc 4.8.1. want build , install thrift 0.9.1. first run ./configure , next make , information warnings (unused variables) treated errors. don't want modify thrift source code need disable gcc feature, makefile doesn't contain -werror flag. how fix ? i trying build thrift 0.9.1 gcc 4.8 on ubuntu 12.04, too. didn't unused variables warnings treated errors, did unused local typedefs warnings failing build. guess same situation ran into. in gcc 4.8, -wall enables new type of warning: -werror=unused-local-typedefs default. passing -wno-unused-local-typedefs when configuring should solve problem: cppflags=-wno-unused-local-typedefs ./configure --without-tests note passed cppflags instead of cxxflags , cflags . build script of thrift 0.9.1 somehow fails pass cflags makefile under c_glib directory, while cppflags did. also, 0.9.1 source tarball released compiling problem on tests. that's why included --without-tests option. ...

c++ - Makefile.Release error: Making Zint Barcode project work in Qt -

after acquiring zint barcode generator went folder backend_qt4 , opened qt project file backend_vcx.pro. project unfortunately not compile, error: makefile.release: no such file or directory what causes error? i'm using qt5.2.1 mingw compiler. note: there frontend_qt4 project, displays same error when i'm trying compile it. edit : downloaded zint-2.4.3.tar.gz from here

enumeration - Writing an enumerator for a JavaScript object -

i'm trying understand how enumerator javascript object can written. came across piece of sharepoint code items of sp list being obtained on client side , , code similar 1 below being performed on sharepoint object. var enumerator = list.getenumerator(); while(enumerator.movenext()) { var currentitem = enumerator.getcurrent(); // actions on currentitem } if write custom object iterated upon using enumerator above, how look? attempt, doesn't work: var list = { items: ["a", "b", "c", "d", "e"], counter: -1, enumerator: { movenext: function() { counter++; // outer object's variable not accessible if(counter >= items.length) return false; else return true; }, getcurrent: function() { return items[counter]; // outer object's variable not accessible } }, getenumerator: function...

c# - Linq cast to list<T> -

i have following classes: public class column { public string name; public string value; } public class columnlist : list<column> {} then do: var cols = (from c in othercolumnlist select new column { name = c.name, }).tolist() columnlist; however returns null. how can cast list? what you're trying equivalent this: animal animal = new animal(); dog dog = animal dog; one possible solution provide constructor takes existing list, , calls base constructor, such as: public class columnlist : list<column> { public columnlist(ienumerable<column> collection): base(collection) { } } and build columnlist existing collection. var collection = othercolumnlist.select(c => new column { name = c.name }); var columnlist = new columnlist(collection); you provide extension method make easier: public static class columnlistextensions { public static tocolumn...

apache commons httpclient - How to disable Kayako REST API DEBUG logs -

i using kayako rest api ticketing service. calling api apache.commons.httpclient.methods.postmethod. in every call kayako rest api write numerous logs in console like: 14:40:33.716 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.useragent = jakarta commons-httpclient/3.1 14:40:33.722 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.protocol.version = http/1.1 14:40:33.723 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.connection-manager.class = class org.apache.commons.httpclient.simplehttpconnectionmanager 14:40:33.723 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.protocol.cookie-policy = default 14:40:33.723 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.protocol.element-charset = us-ascii 14:40:33.723 [http-bio-8080-exec-35] debug o.a.c.h.params.defaulthttpparams - set parameter http.protocol.cont...