Search Results

Search found 4242 results on 170 pages for 'mark tompson'.

Page 82/170 | < Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >

  • Python: Parsing a colon delimited file with various counts of fields

    - by Mark
    I'm trying to parse a a few files with the following format in 'clientname'.txt hostname:comp1 time: Fri Jan 28 20:00:02 GMT 2011 ip:xxx.xxx.xx.xx fs:good:45 memory:bad:78 swap:good:34 Mail:good Each section is delimited by a : but where lines 0,2,6 have 2 fields... lines 1,3-5 have 3 or more fields. (A big issue I've had trouble with is the time: line, since 20:00:02 is really a time and not 3 separate fields. I have several files like this that I need to parse. There are many more lines in some of these files with multiple fields. ... for i in clients: if os.path.isfile(rpt_path + i + rpt_ext): # if the rpt exists then do this rpt = rpt_path + i + rpt_ext l_count = 0 for line in open(rpt, "r"): s_line = line.rstrip() part = s_line.split(':') print part l_count = l_count + 1 else: # else break break First I'm checking if the file exists first, if it does then open the file and parse it (eventually) As of now I'm just printing the output (print part) to make sure it's parsing right. Honestly, the only trouble I'm having at this point is the time: field. How can I treat that line specifically different than all the others? The time field is ALWAYS the 2nd line in all of my report files.

    Read the article

  • Find multiple patterns with a single preg_match_all in PHP

    - by Mark
    Using PHP and preg_match_all I'm trying to get all the HTML content between the following tags (and the tags also): <p>paragraph text</p> don't take this <ul><li>item 1</li><li>item 2</li></ul> don't take this <table><tr><td>table content</td></tr></table> I can get one of them just fine: preg_match_all("(<p>(.*)</p>)siU", $content, $matches, PREG_SET_ORDER); Is there a way to get all the <p></p> <ul></ul> <table></table> content with a single preg_match_all? I need them to come out in the order they were found so I can echo the content and it will make sense. So if I did a preg_match_all on the above content then iterated through the $matches array it would echo: <p>paragraph text</p> <ul><li>item 1</li><li>item 2</li></ul> <table><tr><td>table content</td></tr></table>

    Read the article

  • How to pass in password to pg_dump?

    - by Mark
    I'm trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs: pg_dump dbname | gzip > $(date +%Y-%m-%d).psql.gz Except after running that, it expects me to type in a password. I can't do that if I run it from cron. How can I pass one in automatically?

    Read the article

  • quick java question

    - by mark
    hi, im currently learning stacks in java and have a quick question. what will the following code display if the stack is empty? my guess would be "true"? System.out.println(st.isEmpty());

    Read the article

  • Birthday effect - clarification needed plz.

    - by Mark
    Please help interpret the Birthday effect as described in Wikipedia: A birthday attack works as follows: 1) Pick any message m and compute h(m). 2) Update list L. Check if h(m) is in the list L. 3) if (h(m),m) is already in L, a colliding message pair has been found. else save the pair (h(m),m) in the list L and go back to step 1. From the birthday paradox we know that we can expect to find a matching entry, after performing about 2^(n/2) hash evaluations. Does the above mean 2^(n/2) iterations through the above entire loop (i.e. 2^(n/2) returns to step 1), OR does it mean 2^(n/2) comparisons to individual items already in L.

    Read the article

  • How to display two QuerySets in one table?

    - by Mark
    I have two different QuerySets which both return a list of Users (with different fields). How can I display them both in one HTML table? One Query will always be a subset of the other; I just want to fill in the missing data with 0s. How can I do this?

    Read the article

  • Order a foreach, by the value of a calculation of values in the array

    - by Mark
    I have an array as follows: $players = array( $player = array( 'name' => 'playername', 'speed' => '10', 'agility' => '10', 'influence' => '10' ) etc Then I calculate a $score, based on the sum of speed, agility and influence. $score = $p['speed'] + $p['agility'] + $p['influence']; How can I loop through my array, but order the results from highest to lowest $score? PS- http://pastebin.com/eUEQ5y4u

    Read the article

  • R programming function without ()

    - by Mark Kennedy
    So, I Have the following very simple map.r file. I'm trying to have the user type "click" in interactive mode and then have the function . Since it's a function, the user has to type "click()" how can I make it so that they only have to the word (w/o parentheses), and then have that function do something with the img. So the user types: mydist("image.pnm") click //And then the function click does what it's supposed to mydist <- function(mapfile) { img <- read.pnm(mapfile) plot(img) } click <- function() { //Prompt user to click on img }

    Read the article

  • Best method for creating absolute path in PHP? (See 3 methods listed inside)

    - by mark
    I can create paths with no problem, but I want to know which of these 3 methods is the most rock solid and reliable and will work on the most servers. Right now I am using method 1 in my script and some users are having path issues. I just want the method that will work on any version of php and almost any server config. 1. <?php echo $_SERVER['DOCUMENT_ROOT']; ?> 2. <?php echo getcwd(); ?> 3. <?php echo dirname(__FILE__); ?> Thank you so much for any expertise you can provide about this!

    Read the article

  • Can someone please clarify the Birthday Effect for me?

    - by Mark
    Please help interpret the Birthday effect as described in Wikipedia: A birthday attack works as follows: Pick any message m and compute h(m). Update list L. Check if h(m) is in the list L. if (h(m),m) is already in L, a colliding message pair has been found. else save the pair (h(m),m) in the list L and go back to step 1. From the birthday paradox we know that we can expect to find a matching entry, after performing about 2^(n/2) hash evaluations. Does the above mean 2^(n/2) iterations through the above entire loop (i.e. 2^(n/2) returns to step 1), OR does it mean 2^(n/2) comparisons to individual items already in L.

    Read the article

  • Avoiding instanceof in Java

    - by Mark Lutton
    Having a chain of "instanceof" operations is considered a "code smell". The standard answer is "use polymorphism". How would I do it in this case? There are a number of subclasses of a base class; none of them are under my control. An analogous situation would be with the Java classes Integer, Double, BigDecimal etc. if (obj instanceof Integer) {NumberStuff.handle((Integer)obj);} else if (obj instanceof BigDecimal) {BigDecimalStuff.handle((BigDecimal)obj);} else if (obj instanceof Double) {DoubleStuff.handle((Double)obj);} I do have control over NumberStuff and so on. I don't want to use many lines of code where a few lines would do. (Sometimes I make a HashMap mapping Integer.class to an instance of IntegerStuff, BigDecimal.class to an instance of BigDecimalStuff etc. But today I want something simpler.) I'd like something as simple as this: public static handle(Integer num) { ... } public static handle(BigDecimal num) { ... } But Java just doesn't work that way. I'd like to use static methods when formatting. The things I'm formatting are composite, where a Thing1 can contain an array Thing2s and a Thing2 can contain an array of Thing1s. I had a problem when I implemented my formatters like this: class Thing1Formatter { private static Thing2Formatter thing2Formatter = new Thing2Formatter(); public format(Thing thing) { thing2Formatter.format(thing.innerThing2); } } class Thing2Formatter { private static Thing1Formatter thing1Formatter = new Thing1Formatter(); public format(Thing2 thing) { thing1Formatter.format(thing.innerThing1); } } Yes, I know the HashMap and a bit more code can fix that too. But the "instanceof" seems so readable and maintainable by comparison. Is there anything simple but not smelly?

    Read the article

  • Getting screen height before first display?

    - by Mark
    Hi, I have a ListView. I populate it with 8 items, that's all that fits vertically on the G1. Some of my users are saying the Droid has a taller screen height, and so I can probably add one or two more items to the ListView to take up the additional space provided. How could I measure the available height the screen offers at startup, before the UI is displayed? If I see the height can fit more than 8 items, I'd like to add one or two more rows, Thanks

    Read the article

  • Can you /should you learn SEO techniques

    - by Mark
    I know very little about Search engine optimization however from discussions with other I am now unsure where to start. Are there any books or do these date so quickly that they are obsolete? Do all website give you mis-information or are there any reliable sources? Is it just a case of trial and error and in turn experience? Is it event worth learning the techniques as search engines change their algorithms so regularly? I wonder if it just better to spend the time to ensure you have a regularly updated will written web site with quality content, site map, quality links etc..

    Read the article

  • Passing command line arguments in C#

    - by Mark
    Hi, I'm trying to pass command line arguments to C# application, but I have problem passing something like this: "C:\Documents and Settings\All Users\Start Menu\Programs\App name" even if I add " " to the argument? Any help?? Here is the code: public ObjectModel(String[] args) { if (args.Length == 0) return; //no command line arg. //System.Windows.Forms.MessageBox.Show(args.Length.ToString()); //System.Windows.Forms.MessageBox.Show(args[0]); //System.Windows.Forms.MessageBox.Show(args[1]); //System.Windows.Forms.MessageBox.Show(args[2]); //System.Windows.Forms.MessageBox.Show(args[3]); if (args.Length == 3) { try { RemoveInstalledFolder(args[0]); RemoveUserAccount(args[1]); RemoveShortCutFolder(args[2]); RemoveRegistryEntry(); } catch (Exception e) { } } } And here is what I'm passing: C:\WINDOWS\Uninstaller.exe "C:\Program Files\Application name\" "username" "C:\Documents and Settings\All Users\Start Menu\Programs\application name" The problem is: I can get the first and the second args correct, but the last one it gets like this: C:\Documents

    Read the article

  • MySql database design for a quiz

    - by Mark
    I'm making an online quiz with php and mysql and need a bit of help deciding how to design the database for optimal insert of questions/answers and to select questions for the quiz. The table will hold 80 questions each with 4 possible options plus the correct answer. When retrieving the questions and options from the database I will randomly select 25 questions and their options. Is it better to make a single column for all questions, options, and correct answers? For example: ID | Q | OPT1 | OPT2 | OPT3 | OPT4 | ANS Or would it be better to make a column for each individual question, option, and correct answer? For example: Q1 | Q1_OPT1 | Q1_OPT2 | Q1_OPT3 | Q1_OPT5 | Q1_ANS | Q2 | Q2_OPT1 | Q2_OPT2...

    Read the article

  • There's @interface in my @implementation — why is that?

    - by Mark McDonald
    This is a pretty noobish question – I'm looking at some Cocoa sample code and there's @interface blocks in the .m files as well as the headers. For instance, in the AppDelegate class header, a UIWindow and UI navigation are defined as instance variables, but the @property declarations are actually made in the implementation file. Is there a functional reason for this, is it a stylistic choice, or… ?

    Read the article

  • Are there any good Javascript/Jquery thumbnail script equivalents to TimThimb (PHP)?

    - by Mark
    For those unaware of TimThumb, it will take any image, of any size or dimension and create a thumbnail on the fly to any desired size. The beauty of it is that it really works on any dimension you feed it through a combination of either resizing the image, cropping or zoom cropping the image. Ive been searching for jscript equvalents but they either require the user to actually mask out the thumbs manually (looking for a script that automatically does it to images) or the scripts can't handle images in a different aspect ratio. Thanks for any leads on this!

    Read the article

  • Real time content editing html5

    - by Mark Lauzon
    So I've seen things like WordPress and FCKEditor, and basically a bunch of stuff that uses external code that I can't see or edit. Whenever I ask about editing and saving the content of a page in real time I just get referenced to an API or I get handed code that only changes the page until it's reloaded. What I want to know is how do I code it myself? I want to add real time content editing to a page without the use of someone else's code. I've checked out code for various forums and wikipedia and whatnot, and all of it references code I don't have access to. Is this a thing? Can I edit a page in real time? I thought of writing the edited text to a file on the server, and then when they click save, reading it back into the code to the section they were editing, but I don't know how to do that or if it's even possible. As a side note, I'm very new to html, but not new to coding. EDIT: The structure can be very much like Wikipedia, it doesn't have to be real time, it just has to work

    Read the article

  • How to loop X times in Django?

    - by Mark
    I have user reviews on my site. Each review has a rating of 1-5 stars. I want to print that many stars. How do I do it? I only see {% for X in Y %} which lets you iterate over a list, but not a certain number of times.

    Read the article

< Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >