Posts

Showing posts from 2010

How to create a form programmatically with a couple components on it in Delphi -

Image
i'm working delphi 7 , i'm trying create form programmatically. here's form class stub: unit clststudentinfoform; interface uses forms; type tstudentinfoform = class (tform) end; implementation end. i have button on main form (that's regular form that's supposed create , show form above @ run-time) , when clicked creates , shows student form modal window. show form there's nothing on it. thing can click close button @ upper-right corner of window close it. procedure tlibraryform.btnshowstudentifoformclick(sender: tobject); var f : tstudentinfoform; begin f := tstudentinfoform.createnew(self); f.showmodal; f.free; f := nil; end; i have no idea how add components programmatically-created form (not @ run-time, source code). can me write code adds okay button student form sets caption , form's height , width (the code has written in student form file)? any suggestions , examples highly appreciate

knockout.js - how to show one validation icon for radiobuttons group -

i'm using knockoutjs , knockout validation plugin. i show 1 validation icon radio group, after 'question 1' title. how can this? <label>question 1:</label> <div> <!-- ko foreach: answers --> <div> <input type="radio" data-bind="attr: { value: id, id: id, name: 'answers' }, checked: $parent.selectedvalue" /> <label data-bind="text: text, attr: { for: id }"></label> </div> <!-- /ko --> </div> there jsfiddle example also second question - why validation icons displaying in example? thanks! you can put validation message on element using validationmessage binding handler: this shows validation message : <label>question 1: <span data-bind="validationmessage: selectedvalue"></span> this example shows custom message template : <label>question 1: <input style="di

html - modal window not poping up in ie and Nivo Image Slider image not working after uploaded -

first question: have set page use modal windows pop brief description waterpark attraction , nivo image slider contains few shots of each attraction. can not figure out why window not pop in ie. modal window works in every other browser have tested??? in ie none of buttons on particular page able clicked? second question: when test nivo slider locally works fine. however, once upload slider doesn't work. have made sure scripts, css, images, , pages have been uploaded. i'm stumped. i no means professional @ appreciated. the link page http://splashwaywaterpark.com/attraction call jquery before files jquerymodal.js file come after jquery. solves error in ie script5009: '$' undefined jquerymodal.js, line 2 character 1 so reorder this <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="scripts/jquerymodal.js"></script> in popbox.css

perl - perlbrew fails with "Can't locate Devel/PatchPerl.pm" -

perlbrew fails can't locate devel/patchperl.pm . more precisely, fails run of patchperl spawned off perlbrew . there is in fact devel/patchperl.pm accessible via paths in environment variable perl5lib , perlbrew unconditionally deletes variable before runs perlpatch : delete $env{$_} qw(perl5lib perl5opt); i can't find in perlbrew documentation justifying maneuver. can explain why perlbrew this? edit: below bash script reproduces problem. run (with suitable <path_to_script> ): % env -i home=$home shell=/bin/bash /bin/bash --noprofile --norc bash-3.2$ /bin/bash --norc --noprofile <path_to_script> the script's running time 4 minutes on machine. last few lines of output, including lines showing error below: (cd /tmp/perlbrew_root/build/perl-5.16.3 && rm -f config.sh policy.sh && patchperl && sh configure -de '-dprefix=/tmp/perlbrew_root/perls/perl-5.16.3' '-a'eval:scriptdir=/tmp/perlbrew_roo

sql - extract field only when we have least one registration -

i have 2 tables : author(id_author, date_conf, id_visitor, id_article) visitor(id_visitor, email, registration_date, registration_fees, ...) i want extract articles (id_article) when @ least 1 author have done registration (registration fees not empty or null (logically)) for example, when natural inner join (id_author, registration_fees, id_article, ...) (0, 123.1, 1) (1, null, 1) (2, null, 2) it should extract id_article because has 123.1. authors of id_article 2 didn't pay registration. how can please? i think want want: select id_article author join visitor v on a.id_visitor = v.id_visitor registration_fees not null group id_article

timeout - How to read for X seconds maximum in C++? -

i want program wait read in fifo, if read (i use std::fstream ) lasts more 5 seconds, want exit. is possible or have use alarm absolutely? thank you. i not believe there clean way accomplish portable c++ solution. best option use poll or select on *nix based systems , waitforsingleobject or waitformultipleobjects on windows. you can transparently creating proxy streambuffer class forwards calls real streambuffer object. allow call appropriate wait function before doing actual read. might this... class mystreambuffer : public std::basic_streambuf<char> { public: mystreambuffer(std::fstream& streambuffer, int timeoutvalue) : timeoutvalue_(timeoutvalue), streambuffer_(streambuffer) { } protected: virtual std::streamsize xsgetn( char_type* s, std::streamsize count ) { if(!wait(timeoutvalue_)) { return 0; } return streambuffer_.xsgetn(s, count); } private: b

r - Insert a non-character if a criteria is TRUE -

is possible insert non-character, in case -, if particular criteria met? for example: if there 5 numeric characters (12345), insert - after 2nd numeric character (12-345). i trying fix street addresses. thanks! s = "abc 12345 def" sub("([0-9]{2})([0-9]{3})", "\\1-\\2", s) # "abc 12-345 def" this find first instance of 5 numbers in row , add "-" after second number. see http://stat.ethz.ch/r-manual/r-patched/library/base/html/regex.html r regex syntax.

javascript - I can't get mouse out to work -

so have function prevent body scrolling when sidebar hovered. problem is, can't mouseout function work properly. var currentscroll=0; function lockscroll(){ $(window).scrolltop(currentscroll); } $(document).ready(function (){ $(".sidebarholder, .commentswrapper").hover(function (){ currentscroll=$(window).scrolltop(); $(window).bind('scroll',lockscroll); }) }) my question is, how unbind on mouseout? if this, stops working altogether. $(".sidebarholder, .commentswrapper").mouseout(function(){ currentscroll=$(window).scrolltop(); $(window).unbind('scroll'); }) jquery's hover() has built in "hover off", might helpful: $(".sidebarholder, .commentswrapper").hover( function (){ // hover on currentscroll=$(window).scrolltop(); $(window).bind('scroll',lockscroll); }, function (){ // hover of

android - Application suddenly became incompatible with device(Galaxy Tab 2) -

i have application (today) became incompatible device working on fine. app dragon lords , device samsung galaxy tab 2. have idea have happened here? the last apk uploaded 2 months ago , working fine. today had player report in market app incompatible device. checked on galaxy tab 2 , it's same story. device not rooted have no idea happened. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installlocation="auto" package="mds.dragonlords" android:versioncode="25" android:versionname="1.2.19" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="8" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="com.android.vending.billing" /> <uses-permission android:name="android.permission.get_accounts" /&g

iphone - Objective-C: How to use calling child's version of a method? -

i've run need before. right now, have function called every 0.1 seconds check on how time has elapsed. if exceeds "total time" (which retrieves gettotaltime function) stops. gettotaltime method overridden in children. code function called every 0.1 seconds overridden, original method in parent class uses gettotaltime called using super , needs call child's method of gettotaltime instead of own. is, of course, issue. rewrite code parent in each of children, seems stupid. google searching has show solutions in other languages, not in objective-c. there way this? if not, alternatives? the code function called every 0.1 seconds overridden, original method in parent class uses gettotaltime called using super, needs call child's method of gettotaltime instead of own. your question difficult parse, sounds you've got this: @interface : nsobject // "parent" class - (void) timermethod; - (nsdate*) gettotaltime; // other methods n

delphi - How to put an image in the Activex Control Button -

i not sure how going make procedure put image in button, seems no tbitbtn or tspeedbutton in activex control wizard, when button stretch image stretched. the project .dpr library buttonxcontrol1; uses comserv, buttonxcontrol1_tlb in 'buttonxcontrol1_tlb.pas', buttonimpl1 in 'buttonimpl1.pas' {buttonx: coclass}, about1 in 'about1.pas' {buttonxabout}; {$e ocx} exports dllgetclassobject, dllcanunloadnow, dllregisterserver, dllunregisterserver; {$r *.tlb} {$r *.res} begin end. the project implementation: unit buttonimpl1; {$warn symbol_platform off} interface uses windows, activex, classes, controls, graphics, menus, forms, stdctrls, comserv, stdvcl, axctrls, buttonxcontrol1_tlb; type tbuttonx = class(tactivexcontrol, ibuttonx) private { private declarations } fdelphicontrol: tbutton; fevents: ibuttonxevents; procedure clickevent(sender: tobject); procedure keypressevent(sender: tobject; var key: char

c++ - ZeroMQ share a context with all child processes in a forking server -

i'm writing forking chat server in c++, each incoming client being own process. server-client interactions done though normal sockets zeromq sockets handling message queuing , ipc. basic problem there when server forks accommodate new client, client's process has copy of context (which fork does, right?), when binds sockets context, none of other clients aware of socket. long story short: how each client thread have same context can talk each other through zeromq? i've looked @ various ways share context between processes, , far i'm found this one . problem 1) uses thread pool, , understand what's written there, 5 threads created; server needs support @ least 256 , have @ least many threads, , 2) uses zeromq both talking clients , backend tasks; i'm limited using zeromq backend only. i've looked @ zeromq mailing list , 1 message said fork() orthogonal how zeromq works. mean can't share context across forked child processes? if that's case, ho

iphone - Google Analytic not updated in iOS Cordova 2.0.0 App -

i working on ios app using cordova 2.0.0, , want use google analytics, followed github link step step, unfortunately ga not updated, difference in link readme file "make sure running cordova(phonegap) 1.5.0" , use cordova 2.0.0 see repo updated 2.0.0 , app work right ga not updated and here code call in ondeviceready method, start ga , add event var googleanalytics = window.plugins.googleanalyticsplugin; googleanalytics.starttrackerwithaccountid("xx-xxxxxxxx-x"); googleanalytics.trackevent("category", "action", "label goes here", 666); can 1 or face same problem? kindly follow below link,its helpful , worked me. ----> https://github.com/jelled/google-analytics-cordova-ios

java - Android - Wanting to alternate icon images in a listview using cursorLoader -

i have application displays listview of contacts sorted last, first names. beside each contact image (icon). there 3 kinds of contacts i'd display 3 different images (customers/suppliers/other) have default image set customer. i'm wondering if there's way using cusorloader shown below alternate images on fly, or whether best add method involving cursor in onresume. (onresume called each time need display images). believe simplecursoradapter can take textviews args, if it's possible, maybe compound textview/image work. icons not stored in database, in drawables. thanks in advance replies. @override protected void onresume() { super.onresume(); //starts new or restarts existing loader in manager getloadermanager().restartloader(0, null, this); } /* * filldata method binds simplecursoraadapter listview. */ private void filldata() { string[] = new string[] { contactsdb.column_last_name, contactsdb.column_first_name }; //the xml v

javascript - D3 tree layout add 'title' to leaf nodes only -

i can add title nodes in tree node.append("svg:title").text(function(d) { return d.name + " " + d.size }); how can add title the leaf nodes? i tried: node.selectall('g.leaf.node text').text("title", function(d) { return d.name + " " + d.size }); but didn't work. example titles on nodes http://jsfiddle.net/chrisloughnane/ecu2c/ you can check whether current node has children , add title if doesn't. code be node.append("svg:title").text(function(d) { return d.children ? "" : d.name + " " + d.size; }); note set g.leaf.node class operate on leaves easier if have several things specific them.

jquery - Using a jqueryui dialog, I'm trying to focus on a textarea but the cursor never appears -

i'm using jquery : 1.9.1 jqueryui : 1.10.2 all browsers show same behaviour - so i'm launching jquery dialog anytime right-clicks textarea element. noticed textarea getting focus active cursor when gets right-clicked, call blur() on element rid of cursor. works, no problem. then in dialog, if user clicks "edit" want put cursor active on text area. call show(), , focus() [see code below], doesn't focus back. no errors, nothing happens besides dialog closing want (dialog closes, textarea should have active cursor doesn't). below code, appreciated, i've been trying figure out few hours. identified code expect work doesn't "this problem" html this element jqueryui dialog. when user right-clicks target element, shows content of dialog <div id="popupdialog"> <input type="button" id="editrowbutton" class="contextmenubutton" value="edit"> </di

curl - Airplay http requests -

i'm trying build android controler airplay receiver (contained in tv mediaplayer). i'm using curl testing request , postman , chrome extension builds http requests. requests understood server if use postman, must not reproduce request curl. for example, request asks current position media played: curl -i \ 192.168.1.42:7000/scrub \ -h "connection: keep-alive" \ -h "cache-control: no-cache" \ -h "user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.63 safari/537.31" \ -h "accept: */*" \ -h "accept-language: fr-fr,fr;q=0.8,en-us;q=0.6,en;q=0.4" \ -h "accept-encoding: gzip,deflate,sdch" \ -h "accept-charset: iso-8859-1,utf-8;q=0.7,*;q=0.3" \ returns: http/1.1 200 ok content-type: text/parameters content-length: 38 duration: 0.000000 position: 0.000000 while postman returns correct values: duration: 275.838989 position: 13.000000 the headers used in

ruby - How to extend a custom rails method? -

i have rails model called projects: class project < activerecord::base that has variety of toggle switches, such active, started, paid, etc. i have method return status in human readable format: def status return 'pending' if self.pending? return 'started' if self.started return 'in review' if self.in_review? return 'approved' if self.approved return 'active' if self.active end right have method called status! returns same information in symbol form, inefficient in mind: def status return :pending if self.pending? return :started if self.started return :awarded if self.awarded return :in_review if self.in_review? return :approved if self.approved return :active if self.active end what more status.to_sym can't figure out how make happen. any thoughts? how this: def status return 'pending' if self.pending? return 'started' if self.started return 'in review'

swing - java boxlayout space after adding jpanel -

i have container jpanel in used boxlayout manager , add panels inside in added panel contains label , textfield using flowlayout manager. everytime add panel inside creates annoying big space after added panel. want reduce spacing of panels have tried using setsize , setpreferredsize method adjust it. here code: jpanel global = new jpanel(); global.setlayout(new boxlayout(global, boxlayout.y_axis)); global.setpreferredsize(new dimension(500,312)); global.setsize(500,312); global.setbounds(8, 5, 500, 312); global.setborder(borderfactory.createlineborder(color.black)); global.setbackground(color.white); //elements of global jlabel label1 = new jlabel("global settings"); label1.setalignmentx(component.center_alignment); label1.setfont(new font("tahoma", font.bold, 17)); global.add(label1); global.add(new jseparator()); //name field jpanel c = new jpanel(); c.setsize(100, 1); c.setpreferredsize(new dimension(100,1)); c.setlay

sql - What does this query do? -

i'm studying final exam , comes in past exam: table: nurse - ( nid:int , nname:string, age:real, salary:real, sid:int) table: supervisor - ( sid:int , rating:real) table: worksin - ( nid:int , hid:int , hours:real) table: hospital - ( hid:int , hname:string, tid:int) table: town - ( tid:int , tname:string, mayor:string) explain following query retrieves: select nname nurse n not exists ( (select h.hid hospital h h.town = ‘toronto’) except (select w.hid worksin w n.nid = w.nid)) what query do? can understand subquery returns hospitals in toronto doesn't have nurse work in, don't know how connects not exist part. consider in stages: the set of nurses there not exist hospital in toronto nurse doesn't work. by law of excluded middle becomes the set of nurses nurse works in toronto hospitals note these points raised in discussion commentator: the sub-query

drop down menu - Bootstrap, making <td> a dropdown trigger -

i have structure using bootstrap dropdowns: <div id="navigation" class="row-fluid"> <table class="basic" width="85%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="current" height="60%" align="center" valign="center"> <a href="<? echo base_url(); ?>">home</a> </td> <td class="" align="center" valign="center"> <div style="position: relative"> <a id="dropdown1" class="dropdown-toggle" data-toggle="dropdown">about us</a> <ul class="dropdown-menu dropdown" role="menu" aria-labelledby="dropdown1"> <li><a class="node" tabindex="-1" href="<? echo base_url(); ?>unique/&qu

android - App Development with Ruby on Rails -

is possible create native app ruby on rails on either iphone or android? i know programming language used iphone apps objective c , 1 used android java. friend told me working on making phone app of on iphone , android ruby on rails. thought ruby on rails web application frame , have never heard before(unless creating web app). thought maybe using converter translate ruby of rails objective c , or java. tried asking him detail business guy , recommended use ruby on rails. any thoughts? you can make ios applications using ruby. take @ site

In Scala how to compare current values with previous values while processing a stream? -

Image
i new scala not sure how approach problem ? trying find moving average crossovers stream of quotes. not sure how previous values compare them current values ? if ( fastmovingaverage(n-1) > slowmovingaverage(n-1) && fastmovingaverage(n) < slowmovingaverage(n) ) action package com.example.csv import scala.io.source object fileparser { val timestamp_location = 3 val bid_location = 4 val offer_location = 5 val fast_window_size = 5 val slow_window_size = 10 def main(args: array[string]) = { val records = source.fromfile("sample.csv") .getlines() .drop(1) .map(_.split(",")) .takewhile( _ != null) .sliding(slow_window_size , 1) .foreach(x => movingaverage(x)) } def movingaverage(numbers: seq[array[string]]) = { val listofbids = numbers.map(x => x(bid_location).todouble) val slowaverage = listofbids.reduceleft(_ + _)/numbers.length val fastlistofbids = listofbids.takeright(fast_window_

c - arguments of main? -

i know signature of main is: int main(int argc, char **argv); but don't know why main work too: main(a){} what's 'a' doing here? why compiler don't show error?? because havn't declare 'a' before use it. it's feature of older c code called "implicit int". variable type not specified assumed int . similarly, function return type not specified assumed return int . it's considered deprecated , becomes useful in obfuscated code , code golf . so should read as int main(int a) {} where int s have been omitted because implicit. as whozcraig mentions, standards point-of-view not conforming , not portable . pragmatically, lot of compilers let away when not in standards-conformance mode. implicit int behavior doesn't out of declaring variables, however. main(a){ b,c; // int declarations c = 5; b = c + 10; d = b; // no! d not declared you, implicit int happening. return 0; }

sql - Username or Userid -

i've seen many discussion whether better use userid or username primary key table. userid allow flexibility of later changing username if desired. way implement security. however, username unique identifier. if choose userid primary key, best way enforce username take on unique value? if choose username, problems should aware? i declare userid primary key there other tables referencing user record through userid , thereby useful enforce foreign key constraints. if username needs unique, declare non null column , define unique key constraint. non null property prevent single null value allowed unique key constraint in column. so, set on username similar of primary key .

C# Program addition operator for Point -

i'm using c# xna , found when trying add 2 points won't let me. there way can add point class allow code run. point = new point(3,4); point b = new point(6,2); point c = + b; //should equal new point(9,6); you overload + operator - this: class point { public int x { get; private set; } public int y { get; private set; } public point(int x, int y) { x = x; y = y; } public static point operator +(point p1, point p2) { return new point(p1.x + p2.x, p1.y + p2.y); } } now, code compiles work expect to: point = new point(3, 4); point b = new point(6, 2); point c = + b; //should equal new point(9,6); - , :) more info on operator overloading can found on msdn .

c - Why is kfifo.h so full of #define statements -

this question has answer here: when use function-like macros in c 6 answers kfifo.h made entirely of #define . why that? why have not declared functions in h file "normally" done. [edit] it seems question interpreted questioning of implementation rather ment ask, why implementation better, learning standpoint. anyway, since didn't know looking @ "function-like macros" voting close since it's obviosly duplicate. it permitted have lot of macros. why trouble you? a macro #define struct_kfifo_ptr(type) \ struct __struct_kfifo_ptr(type, 0, type) is not function-like macro. a macro #define kfifo_initialized(fifo) ((fifo)->kfifo.mask) could used on left side of assignment (even if should not that). , shorter write corresponding inline function static inline unsigned kfifo_initialezed_f(struct __kfifo *fifo) {

c++ - Sharpening an Image - Accessing neighbor pixels -

Image
please have @ following code #include <iostream> #include <opencv2\core\core.hpp> #include <opencv2\highgui\highgui.hpp> using namespace std; using namespace cv; void sharpen(mat &,mat); int main() { mat image,result; try { image = imread("c:/users/public/pictures/sample pictures/desert.jpg"); if(!image.data) { throw 1; } } catch(int i) { cout << "image unable reae" << endl; } sharpen(image,result); waitkey(0); } void sharpen(mat &image,mat result) { //result = image.clone(); result.create(image.size(), image.type()); //for rows except first , last for(int i=1;i<image.rows-1;i++) { const uchar *previous = image.ptr<const uchar>(i-1); const uchar *next = image.ptr<const uchar>(i+1); const uchar *current = image.ptr<const uchar>(i); uchar *output = result.pt

html - target ie and non-ie not work? my ie version's ie10 -

here's code. when using ie, want show "please change browser!", , non-ie browsers can see other code. doesn't work in ie10 (ie 10 doesn't show h1 other code) what's wrong code? <!doctype html> <html> <head> <meta charset="utf-8"> <title>sisu|swap</title> <link type="text/css" rel="stylesheet" href="1.css"> </head> <body> <!--[if ie]> <h1 style="color: white">please change browser!</h1> <![endif]--> <!--[if !ie]>--> <header> <img src="imgs/header.jpg" /> </header> <footer> </footer> </body> </html> <!--<![endif]--> internet explorer 10 doesn't support conditional comments, see msdn page conditional comments . important   as of internet explorer 10, conditional comments no longer supported standards mode. use feature detectio

oop - How to make PHP libraries loosely coupled? -

i have libraries in 'framework' routing, config, logger,... want them independent of each other, of known php frameworks make them. i understand principles of loose coupling, have no clue how follow both loose coupling , dry principles. if make routing library config , logger, don't repeat myself, if want use router on own won't work. if write logging , config code routing library, repeat myself. loose coupling means components not expect concrete instance 1 instance has compatible interface. each collaborator can replaced different 1 of same type. code not dependent on concrete implementation of 1 of longer. so: do not use: global (static) functions foo:bar(); class based programming (passing classname around) stream_wrapper_register("var", "variablestream"); global constants if ( !defined('abspath') ) define('abspath', dirname(__file__) . '/'); but: use objects $foo->bar();

mobile - Cross Platform Application Deployment Tool -

i have developed mobile application sencha touch working on ios , android devices. works on chrome , safari , it's chrome packaged app , accessible form chrome web store. has php parts application's backbone. because source code open source can take whole structure @ github https://github.com/umrashrf/iqra-university-smartphone-app . now cool except deploying application pain. whenever change in /sencha folder, have update /android , /ios , , ftp chnaged stuff. note don't replace folders /sencha folder files need modified too. example, ftp stuff web, have make sure /sencha/index.html don't have cordova.js in there android , ios version do. because baseurl in /sencha/app.js relative url in development mode, have change absolute internet url android , ios production builds. is there deployment tool can tell files send /android , /ios , ftp ? , specify somehow change files different production builds? updated also when build android , ios, have increment

ios - Parse.com and Facebook login, runs infinite loop -

i updated both parse , facebook ios sdks latest versions, , when try login using facebook app crashes, , debugger can see calling 3-4 methods in endless loop. my login code looks this: - (void)opensession { uiviewcontroller *topviewcontroller = self.window.rootviewcontroller; nsarray *permissions = [nsarray arraywithobjects:@"user_likes", @"friends_likes", nil]; // login pfuser using facebook [pffacebookutils loginwithpermissions:permissions block:^(pfuser *user, nserror *error) { if (!user) { if (!error) { nslog(@"uh oh. user cancelled facebook login."); } else { nslog(@"uh oh. error occurred: %@", error); } } else if (user.isnew) { nslog(@"user facebook signed , logged in!"); if ([[topviewcontroller presentedviewcontroller] iskindofclass:[paloginviewcontroller class]]) { [topviewcontroll

.net - Multiple inhertinace -

i have classes having .net control: class mytextbox : inherits mycontrol control textbox i use inheritance instead of having variable containing .net control: class mytextbox : inherits textbox since multiple inheritance not supported in .net, there way me inherit mycontrol class , having implementation of .net textbox? class mycontrol : inherits control class mytextbox : inherits mycontrol (all methods, property, events of textbox class) so can have attributes/operations of textboxes, comboboxes , whatever in subclasses plus personal 1 , generic atts/ops on mycontrol class inherited subones. as said, .net (and modern languages , oop environments) won't support multi-inheritance - , design decision -. not workaround actual solution wrapping . if want control mycontrol , textbox there're other ways of getting such relationship: interfaces . your specialized textbox should inherit .net built-in textbox control class , implement imycontr

python - Functions throws error on recursing large numbers -

i'm using python 2.7.3 , have function: def f(n): if n == 0: return 0 else: return (n % 3 == 0 or n % 5 == 0) * n + f(n - 1) f(999) it works until f(993), not f(999). when try, infinite amount of errors keep popping out. don't it. can tell me what's wrong? edit: answers. guess i'm better off using iteration in python. better off using iterative: def f(n): s = 0 while n > 0: s += (n%3==0 or n%5==0)*n n -= 1 return s print f(999) which outputs: 233168 also 1 write sum : def f(n): return sum((n%3==0 or n%5==0)*n n in reversed(range(1,n+1)))

c++ - Passing "constant pointers" to functions -

i've written program performs various operations on binary tree. @ beginning set null root pointer, call couple of insert() functions add new nodes tree. finally, call search() function finds requested structure node , returns it. insert() function takes 2 parameters - reference root pointer, , constant int key, converted node structure , added tree search() function takes "constant root pointer" - not reference, because want operate on local pointer directly, , don't want changed. other argument takes int key. this whole program: #include <iostream> struct node { node *p; // parent node *left, *right; int key; }; void insert(node *&root, const int key) { node newelement = {}; newelement.key = key; node *y = null; while(root) { if(key == root->key) exit(exit_failure); y = root; root = (key < root->key) ? root->left : root->right; } newelement.p = y;

javascript - DOM how to add more than one style in a div -

i'm trying add more 1 style attribute using dom setattribute , doesn't work. how can using javascript? var modificar = document.getelementbyid('opciones'); modificar.setattribute('style','float:left'); modificar.setattribute('style','margin:0px'); setattribute working ok, since invoking twice, result of first call gets overridden second one. either do: modificar.setattribute('style','float: left; margin:0px;'); or use style attribute suggested in answer.

java - Activities and their lifecycle -

consider this: activity a activity b activity c activity started when clicking on launcher icon. activity b started activity - nothing special. activity c should started app (not on click or similar ), broadcast. the problem: when activity c started app automatically, , when press home button on activity, , when click on lanuncher icon (to show main activity - ), shows me activity c. if press button on activity, can go activity a, no problem. how solve issue? killing activity c, on home button press, or other way this? in manifest of activity put android:launchmode="singletask" android:cleartaskonlaunch="true" , in rest of activities put android:cleartaskonlaunch="false" , solve problem. hope you.

grammar - ANTLR4 Mutually Left-recursive Error When Parsing C++ Source -

i'm trying parse subset of cpp source syntax. follow antlr4 parser rules directly copied c++ language specification (except hypens replaced underscores): abstract_declarator: ptr_operator abstract_declarator? | direct_abstract_declarator ; direct_abstract_declarator: direct_abstract_declarator? '(' parameter_declaration_clause ')' cv_qualifier_seq? exception_specification? | direct_abstract_declarator? '[' constant_expression? ']' | '(' abstract_declarator ')' ; but got error when org.antlr.v4.tool parsing grammar: error(119): cppprocessor.g4::: following sets of rules mutually left-recursive [direct_abstract_declarator] it seems direct_abstract_declarator? syntax @ left hand side causes error. how should correct it? why can't antlr4 support it? manually refactoring rules form doesnt produce error: direct_abstract_declarator: direct_abstract_declarator '(' parameter_declaratio