Search Results

Search found 5435 results on 218 pages for 'ones and zeroes'.

Page 9/218 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Perl - Calling subclass constructor from superclass (OO)

    - by Emmel
    This may turn out to be an embarrassingly stupid question, but better than potentially creating embarrassingly stupid code. :-) This is an OO design question, really. Let's say I have an object class 'Foos' that represents a set of dynamic configuration elements, which are obtained by querying a command on disk, 'mycrazyfoos -getconfig'. Let's say that there are two categories of behavior that I want 'Foos' objects to have: Existing ones: one is, query ones that exist in the command output I just mentioned (/usr/bin/mycrazyfoos -getconfig`. Make modifications to existing ones via shelling out commands. Create new ones that don't exist; new 'crazyfoos', using a complex set of /usr/bin/mycrazyfoos commands and parameters. Here I'm not really just querying, but actually running a bunch of system() commands. Affecting changes. Here's my class structure: Foos.pm package Foos, which has a new($hashref-{name = 'myfooname',) constructor that takes a 'crazyfoo NAME' and then queries the existence of that NAME to see if it already exists (by shelling out and running the mycrazyfoos command above). If that crazyfoo already exists, return a Foos::Existing object. Any changes to this object requires shelling out, running commands and getting confirmation that everything ran okay. If this is the way to go, then the new() constructor needs to have a test to see which subclass constructor to use (if that even makes sense in this context). Here are the subclasses: Foos/Existing.pm As mentioned above, this is for when a Foos object already exists. Foos/Pending.pm This is an object that will be created if, in the above, the 'crazyfoo NAME' doesn't actually exist. In this case, the new() constructor above will be checked for additional parameters, and it will go ahead and, when called using -create() shell out using system() and create a new object... possibly returning an 'Existing' one... OR As I type this out, I am realizing it is perhaps it's better to have a single: (an alternative arrangement) Foos class, that has a -new() that takes just a name -create() that takes additional creation parameters -delete(), -change() and other params that affect ones that exist; that will have to just be checked dynamically. So here we are, two main directions to go with this. I'm curious which would be the more intelligent way to go.

    Read the article

  • Should you declare methods using overloads or optional parameters in C# 4.0?

    - by Greg Beech
    I was watching Anders' talk about C# 4.0 and sneak preview of C# 5.0, and it got me thinking about when optional parameters are available in C# what is going to be the recommended way to declare methods that do not need all parameters specified? For example something like the FileStream class has about fifteen different constructors which can be divided into logical 'families' e.g. the ones below from a string, the ones from an IntPtr and the ones from a SafeFileHandle. FileStream(string,FileMode); FileStream(string,FileMode,FileAccess); FileStream(string,FileMode,FileAccess,FileShare); FileStream(string,FileMode,FileAccess,FileShare,int); FileStream(string,FileMode,FileAccess,FileShare,int,bool); It seems to me that this type of pattern could be simplified by having three constructors instead, and using optional parameters for the ones that can be defaulted, which would make the different families of constructors more distinct [note: I know this change will not be made in the BCL, I'm talking hypothetically for this type of situation]. What do you think? From C# 4.0 will it make more sense to make closely related groups of constructors and methods a single method with optional parameters, or is there a good reason to stick with the traditional many-overload mechanism?

    Read the article

  • "Function object is unsubscriptable" in basic integer to string mapping function

    - by IanWhalen
    I'm trying to write a function to return the word string of any number less than 1000. Everytime I run my code at the interactive prompt it appears to work without issue but when I try to import wordify and run it with a test number higher than 20 it fails as "TypeError: 'function' object is unsubscriptable". Based on the error message, it seems the issue is when it tries to index numString (for example trying to extract the number 4 out of the test case of n = 24) and the compiler thinks numString is a function instead of a string. since the first line of the function is me defining numString as a string of the variable n, I'm not really sure why that is. Any help in getting around this error, or even just help in explaining why I'm seeing it, would be awesome. def wordify(n): # Convert n to a string to parse out ones, tens and hundreds later. numString = str(n) # N less than 20 is hard-coded. if n < 21: return numToWordMap(n) # N between 21 and 99 parses ones and tens then concatenates. elif n < 100: onesNum = numString[-1] ones = numToWordMap(int(onesNum)) tensNum = numString[-2] tens = numToWordMap(int(tensNum)*10) return tens+ones else: # TODO pass def numToWordMap(num): mapping = { 0:"", 1:"one", 2:"two", 3:"three", 4:"four", 5:"five", 6:"six", 7:"seven", 8:"eight", 9:"nine", 10:"ten", 11:"eleven", 12:"twelve", 13:"thirteen", 14:"fourteen", 15:"fifteen", 16:"sixteen", 17:"seventeen", 18:"eighteen", 19:"nineteen", 20:"twenty", 30:"thirty", 40:"fourty", 50:"fifty", 60:"sixty", 70:"seventy", 80:"eighty", 90:"ninety", 100:"onehundred", 200:"twohundred", 300:"threehundred", 400:"fourhundred", 500:"fivehundred", 600:"sixhundred", 700:"sevenhundred", 800:"eighthundred", 900:"ninehundred", } return mapping[num] if __name__ == '__main__': pass

    Read the article

  • EXC_BAD_ACCESS in NSURLConnection: how to debug?

    - by baswell
    I have an iPhone app that downloads URLs. (PDFs to display) Easy: self.conn = [NSURLConnection connectionWithRequest:self.request delegate:self]; where self.conn is a retained property. For specific URLs, this throws EXC_BAD_ACCESS. The URL is valid and is constructed in the same way as URLs that do work. (90% of URLs are fine) These ones work: http://www.airservicesaustralia.com/publications/current/ersa/FAC_YARG_11-Mar-2010.pdf http://www.airservicesaustralia.com/publications/current/ersa/FAC_YARK_11-Mar-2010.pdf These don't: http://www.airservicesaustralia.com/publications/current/ersa/FAC_YAMK_11-Mar-2010.pdf http://www.airservicesaustralia.com/publications/current/ersa/FAC_YATN_11-Mar-2010.pdf Spot the difference? Yeah, me neither. Also no difference in response headers from the server for them. To clarify, the ones that work ALWAYS work, the ones that don't NEVER work. So not some random release/retain issue it seems. For the ones that don't work, none of the methods in my delegate are ever called, it fails hard before that. And with no error message, just EXC_BAD_ACCESS. Sooo.... Any way to debug what is going on inside NSURLConnection?

    Read the article

  • Three native monitors on Dell OptiPlex 9010

    - by matthewk
    http://www.dell.com/uk/business/p/optiplex-9010/pd says: Configure your workspace the way you want it with support for up to three native monitors via DP/DP/VGA ports. So I ordered one, and have connected three monitors, but I can only enable two at a time. It can be both of the ones connected by DisplayPort, or one of the ones connected by DisplayPort and the one connected by VGA. Does anyone know whether it really is possible to enable all three at once, and if so, how?

    Read the article

  • How to backup or export PowerStrip display profiles?

    - by Sk8erPeter
    I would like to save two of my saved PowerStrip display profiles. Earlier I set 720x540 resolution and some other settings (frequency, etc.) to another display device usually used in extended mode, which is now NOT connected: But when I go to "Advanced timing options", I see some different settings. I thought I could copy settings with the copy icon , but this way I would copy the wrong ones, not the predefined ones (with the 720x540 resolution): What is the best method to "export" these settings before formatting the hard drive?

    Read the article

  • Displaying Unicode on Chrome vs Firefox

    - by abel
    Unicode Rendering: Firefox vs Chrome OS: Windows XP SP3 My question is about the rendering of this post on Firefox vs Chrome. I can see a lot of boxes on Chrome, not so much on Firefox. Firefox: Chrome: What do I do? Update: Update 2 Changed Sans Serif fonts on Chrome to Arial Unicode and restarted Update 3 This is inspired by @Arjan's references The smilies on Firefox(The reference smilies are the ones below) The smilies on Chrome(The reference smilies are the ones below) Update: The source of the above post is displayed as below Firefox Chrome

    Read the article

  • Displaying Unicode (Bobince's post) on Chrome vs Firefox

    - by abel
    Unicode Rendering: Firefox vs Chrome OS: Windows XP SP3 My question is about the rendering of this post on Firefox vs Chrome. I can see a lot of boxes on Chrome, not so much on Firefox. Firefox: Chrome: What do I do? Update: Update 2 Changed Sans Serif fonts on Chrome to Arial Unicode and restarted Update 3 This is inspired by @Arjan's references The smilies on Firefox(The reference smilies are the ones below) The smilies on Chrome(The reference smilies are the ones below) Update: The source of the above post is displayed as below Firefox Chrome

    Read the article

  • How to merge .rpmnew files in Pluggable Authentication Modules (PAM)?

    - by Question Overflow
    A few .rpmnew files are being created after performing an upgrade of the Fedora OS. The normal procedure for merging .rpmnew files into the original ones is to compare the differences, make the necessary changes to the configuration on the .rpmnew files, and replace the original files with the new ones. However, the files contained in /etc/pam.d are links to files with same the filename appended with -ac, example: password-auth links to password-auth-ac and has password-auth.rpmnew as upgrade. How do I go about merging these files?

    Read the article

  • Is PLC speed affected by mixing different devices?

    - by CFP
    Hello everyone! At home, I have 4 PLC devices for my home network. Two of them are 85Mb/s powerlan PLC adapters, while the others are 10Mbps powerlan PLC adapters. I have not been able to determine reliably whether the presence of the 10Mb/s ones impact on the speed of the 85Mb/s ones. Is it possible that the bitrate is limited by the slowest devices on the network? Thanks!

    Read the article

  • Fibre channel long distance woes

    - by Marki
    I need a fresh pair of eyes. We're using a 15km fibre optic line across which fibrechannel and 10GbE is multiplexed (passive optical CWDM). For FC we have long distance lasers suitable up to 40km (Skylane SFCxx0404F0D). The multiplexer is limited by the SFPs which can do max. 4Gb fibrechannel. The FC switch is a Brocade 5000 series. The respective wavelengths are 1550,1570,1590 and 1610nm for FC and 1530nm for 10GbE. The problem is the 4GbFC fabrics are almost never clean. Sometimes they are for a while even with a lot of traffic on them. Then they may suddenly start producing errors (RX CRC, RX encoding, RX disparity, ...) even with only marginal traffic on them. I am attaching some error and traffic graphs. Errors are currently in the order of 50-100 errors per 5 minutes when with 1Gb/s traffic. Optics Here is the power output of one port summarized (collected using sfpshow on different switches) SITE-A units=uW (microwatt) SITE-B ********************************************** FAB1 SW1 TX 1234.3 RX 49.1 SW3 1550nm (ko) RX 95.2 TX 1175.6 FAB2 SW2 TX 1422.0 RX 104.6 SW4 1610nm (ok) RX 54.3 TX 1468.4 What I find curious at this point is the asymmetry in the power levels. While SW2 transmits with 1422uW which SW4 receives with 104uW, SW2 only receives the SW4 signal with similar original power only with 54uW. Vice versa for SW1-3. Anyway the SFPs have RX sensitivity down to -18dBm (ca. 20uW) so in any case it should be fine... But nothing is. Some SFPs have been diagnosed as malfunctioning by the manufacturer (the 1550nm ones shown above with "ko"). The 1610nm ones apparently are ok, they have been tested using a traffic generator. The leased line has also been tested more than once. All is within tolerances. I'm awaiting the replacements but for some reason I don't believe it will make things better as the apparently good ones don't produce ZERO errors either. Earlier there was active equipment involved (some kind of 4GFC retimer) before putting the signal on the line. No idea why. That equipment was eliminated because of the problems so we now only have: the long distance laser in the switch, (new) 10m LC-SC monomode cable to the mux (for each fabric), the leased line, the same thing but reversed on the other side of the link. FC switches Here is a port config from the Brocade portcfgshow (it's like that on both sides, obviously) Area Number: 0 Speed Level: 4G Fill Word(On Active) 0(Idle-Idle) Fill Word(Current) 0(Idle-Idle) AL_PA Offset 13: OFF Trunk Port ON Long Distance LS VC Link Init OFF Desired Distance 32 Km Reserved Buffers 70 Locked L_Port OFF Locked G_Port OFF Disabled E_Port OFF Locked E_Port OFF ISL R_RDY Mode OFF RSCN Suppressed OFF Persistent Disable OFF LOS TOV enable OFF NPIV capability ON QOS E_Port OFF Port Auto Disable: OFF Rate Limit OFF EX Port OFF Mirror Port OFF Credit Recovery ON F_Port Buffers OFF Fault Delay: 0(R_A_TOV) NPIV PP Limit: 126 CSCTL mode: OFF Forcing the links to 2GbFC produces no errors, but we bought 4GbFC and we want 4GbFC. I don't know where to look anymore. Any ideas what to try next or how to proceed? If we can't make 4GbFC work reliably I wonder what the people working with 8 or 16 do... I don't assume that "a few errors here and there" are acceptable. Oh and BTW we are in contact with everyone of the manufacturers (FC switch, MUX, SFPs, ...) Except for the SFPs to be changed (some have been changed before) nobody has a clue. Brocade SAN Health says the fabric is ok. MUX, well, it's passive, it's only a prism, nature at it's best. Any shots in the dark? APPENDIX: Answers to your questions @Chopper3: This is the second generation of Brocades exhibiting the problem. Before we had 5000s, now we have 5100s. In the beginning when we still had the active MUX we rented a longdistance laser once to put it into the switch directly in order to make tests for a day, during that day of course it was clean. But as I said, sometimes it's clean just like that. And sometimes it's not. Alternative switches would mean to rebuild the entire SAN with those only to test. Alternative SFPs, well they're hard to come by just like that. @longneck: The line is rented. It's a dark fibre (9um monomode) so there's noone else on it. Sure there are splices. I can't go and look but I have to trust they have been done correctly. As I said the line has been checked and rechecked (using an optical time-domain reflectometer). Obviously you don't have all this equipment yourself because it's way too expensive. @mdpc: What would be the "wrong" type of cable according to you? Up to the switch everything is monomode, yes. The connectors are the correct ones too. Yeah I know there are the green ones where the fibre is cut off at a certain angle etc. But we have the correct ones for all that I know. Progress Report #1 We have had two fabrics (=2x2 switches) with Brocade 5100s with FabricOS 6.4.1 and two fabrics (another 2x4 switches) on FabricOS 7.0.2. On the longdistance ISLs (one in each fabric) it turned out that with FOS 6.4.1 setting it to long distance issues warnings about the VC Init setting and consequently the fill word. But those are only warnings. FOS 7.0.2 requires you to do modifications to VCI and the fillword for long distance links. Setting FOS 6.4.1 to the LS (long-distance static distance) setting with wrong VCI and fillword setting made the whole fabric inoperational (stuck in an SCN loop, use fabriclog -s to see, you don't see it anywhere else, no port error counters or anything increasing). Currently I'm giving the one fabric with the IMHO more correct settings a beating and it seems to do fine, whereas the other one without much traffic still has errors here and there. In short: We have eliminated the active part of the MUX (the FC retimer). We are putting the long distance SFPs into the end equipment themselves. Just to be sure we bought new monomode cables to connect the end equipment to the remaining passive part of the MUX. We are now trying out several long distance configs. It's almost black magic. Everything that happens is mostly empirical, noone seems to have a clue what are the exact reasons to do something. ("We have tried this, and it didn't work, then we tried that and it worked, so we stuck with that." But noone really seems to know why.) I'll keep you updated. Progress Report #2 We got the new lasers for one of the fabrics on warranty. It's ultra clean even on 4GbFC. They're transmitting with roughly 2mW (3dBm) whereas the others are only at 1.5mW (1.5dBm) although that should really be enough. The other fabric (where the lasers are apparently ok) still produces one or two CRCs infrequently. Using sfpshow the SFP producing the actual RX errors shows Status/Ctrl: 0x82 Alarm flags[0,1] = 0x5, 0x40 Warn Flags[0,1] = 0x5, 0x40 Now I'll have to find out what that means. Not sure if it was there before. Well I'll first clear my head with a week of vacation. 8-)

    Read the article

  • cron job email customization

    - by user12145
    I have a list of cronjobs where some executes daily and others execute very 15 minutes. I do want to receive an email for the ones executed daily, but wants email disabled for the ones executing every 15 minutes(or maybe receive a daily email), is there a way to do this in crontab?

    Read the article

  • Removing old computers on a domain

    - by Ryaner
    The Windows Domain I manage has hundreds of computer names which I don't recognise and I'd like to remove old ones which aren't in use before trying to track down the misnamed ones. Is there someway to see when the last time a machine logged onto the network? Either via dhcpd or a user login event or something else.

    Read the article

  • Is there an "include" procedure in vimrc?

    - by Somebody still uses you MS-DOS
    I have some configuration in my vimrc. Some generic ones, and some other really specific. I would like to share this config with some co workers, but a lot of them don't need these specific ones. Instead of editing a bunch of different vimrc, I would like to know if it's possible to have an "include" directive - something like a file named ".vimrc_module" and called from vimrc. Is it possible?

    Read the article

  • Renicing complex multithreaded applications in Linux

    - by Vi
    Applications (especially big Java and C++ ones) often shows up as multiple lines in htop, each have separate PID and separate nice level. Also application can spawn a lot of child processes (like as in aptitude update), so I need to affect both parent one (to make new children have new priority) and child ones (to bring the effect immediately, not after the child terminates) How can I apply "renice" or "ionice" or "schedtool" to already launched big application?

    Read the article

  • Plesk not working after restart?

    - by user37888
    Has anyone had a problem where you restarted your Plesk server with the services and only 1 domain works out of all the ones you have? Only one domain will work out of all of the ones on our server and we cannot understand why this is happening.

    Read the article

  • Refurbished vs. Used monitors

    - by Timur Sadykov
    I am looking for additional monitor, I'm trying to save some money by looking on used and refurbished ones. Used monitors are usually noticeably cheaper, but it is quite difficult to find something close to the desired model. Their condition also vary significantly. Refurbished ones eliminate these problems for some additional money. Is there anything to look out for with refurbished monitors? Do many of the have lots of broken pixels etc?

    Read the article

  • What logs should I collect from a Windows server network?

    - by Cygnus X
    I'm setting up a log collection server for my Windows network (about 30 servers ranging from 2003 to 2008 R2, and about 300 vista/7 clients), and I was wondering which logs are good to collect and which ones are a waste of time. I'm going to collect the obvious ones (system, security, event, firewall, and role specific logs) but are there any others I should be worried about? I'm using Splunk if that helps answer the question.

    Read the article

  • Do newer physical interfaces make a better linux firewall?

    - by pfyon
    At work we use an old (10 year old) linux box with 4 interfaces to act as router/firewall for the network. There's never really been a need to change it since it's stable and handles all our needs. I'm wondering, though, would replacing the network interfaces with newer ones provide a benefit? Besides the obvious bandwidth increase (eg. 100MBit to GBit), would there be a latency reduction, or do newer cards pretty much do the same thing as old ones?

    Read the article

  • Move / SVMOTION Replica / Source from Datastore to another

    - by Gdriver
    Hi, I need to evacuate 2 Datastores. Now the only things on those 2 datastores are 4 replica / source machines. These are productive ones which means, there are a lot of linked clones linked to these replicas. So there is no way to recompose these ones. If I would unprotect the entity the linked clones wouldn´t work anymore right? Is there a way to move the replicas to another datastore without "killing" the linked clones?

    Read the article

  • Infix to Postfix and unary/binary operators

    - by Jaapjan
    I have a piece of code that converts an infix expression to an expression tree in memory. This works just fine. There's just one small trouble. I just connect work out how to involve the unary operators correctly (the right associative ones). With the following infix expression : +1 + +2 - -3 - -4 I would expect an RPN of: 1+2++3-4-- Yet, none of the online infix-post converters I can find handle this example in the way I would expect. Does anyone have a clear explanation of handling right associative operators, specifically the binary ones that can be mistaken for the unary ones?

    Read the article

  • divide the image into 3*3 blocks

    - by Jayanth Silesh
    I have a matrix that does not happen to have dimensions that are multiples of 3 or it might. How can we divide the entire image into blocks of 3*3 matrices. (Can ignore the last ones which does not come under the 3*3 multiples. Also, the 3*3 matrices can be be saved in arrays. a=3; b=3; %window size x=size(f,1)/a; y=size(f,2)/b; %f is the original image m=a*ones(1,x); n=b*ones(1,y); I=mat2cell(f,m,n);

    Read the article

  • Codechef practice question help needed - find trailing zeros in a factorial

    - by manugupt1
    I have been working on this for 24 hours now, trying to optimize it. The question is how to find the number of trailing zeroes in factorial of a number in range of 10000000 and 10 million test cases in about 8 secs. The code is as follows: #include<iostream> using namespace std; int count5(int a){ int b=0; for(int i=a;i>0;i=i/5){ if(i%15625==0){ b=b+6; i=i/15625; } if(i%3125==0){ b=b+5; i=i/3125; } if(i%625==0){ b=b+4; i=i/625; } if(i%125==0){ b=b+3; i=i/125; } if(i%25==0){ b=b+2; i=i/25; } if(i%5==0){ b++; } else break; } return b; } int main(){ int l; int n=0; cin>>l; //no of test cases taken as input int *T = new int[l]; for(int i=0;i<l;i++) cin>>T[i]; //nos taken as input for the same no of test cases for(int i=0;i<l;i++){ n=0; for(int j=5;j<=T[i];j=j+5){ n+=count5(j); //no of trailing zeroes calculted } cout<<n<<endl; //no for each trialing zero printed } delete []T; } Please help me by suggesting a new approach, or suggesting some modifications to this one.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >