• Lucid Dreaming - Dream Views




    Results 1 to 24 of 24
    1. #1
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14

      DV Elim Stats - Bash Scripts

      With round 2 of the elimination game set to start on Wednesday, I thought some people would be interested in the scripts I made for the stats.

      These are a lot more in-depth than the first round stats, and in particular, use concurrent processing to speed up execution.

      It may not be the most efficient of programs (in fact, I'm sure someone will spot bits that are highly inefficient), but I'm quite proud of it none-the-less

      The main program is called "elim_start"
      This program sets up some global stuff, forks off the parallel processing work for tracking individual users' scores, then does the top-x totals and pulls everything together.

      For obvious reasons, I've altered the login credentials of my FTP account

      elim_start
      Spoiler for elim_start:


      The parallel processing is governed by this wrapper script

      parallel
      Spoiler for parallel:


      And finally, the per-user tracking script

      user_loop
      Spoiler for user_loop:



      *edit*
      The finished product can be seen here
      (obviously, it's blank until the game actually starts)
      http://www.snoopy.force9.co.uk/dv_elim.html
      Last edited by Ynot; 09-22-2009 at 12:58 AM.
      (\_ _/)
      (='.'=)
      (")_(")

    2. #2
      Member Tyler's Avatar
      Join Date
      Apr 2008
      Gender
      Location
      North Carolina
      Posts
      1,587
      Likes
      36
      I don't understand this a bit.
      This shit never happens to me

    3. #3
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Whoa.

    4. #4
      Member Tyler's Avatar
      Join Date
      Apr 2008
      Gender
      Location
      North Carolina
      Posts
      1,587
      Likes
      36
      OH!
      Now I understand!
      This is all automated?
      This shit never happens to me

    5. #5
      Rational Spiritualist DrunkenArse's Avatar
      Join Date
      May 2009
      Gender
      Location
      Da Aina
      Posts
      2,941
      Likes
      1092
      Is there a reason you felt the need to write it in shell script as opposed to python, perl or ruby?
      Previously PhilosopherStoned

    6. #6
      Legend Jeff777's Avatar
      Join Date
      Aug 2007
      LD Count
      Over 9,000
      Gender
      Posts
      8,055
      Likes
      1519
      Good job Ynot.

      Quote Originally Posted by PhilosopherStoned View Post
      Is there a reason you felt the need to write it in shell script as opposed to python, perl or ruby?
      Surely you can make 16 helpful posts before the 23rd.
      Things are not as they seem

    7. #7
      Member Tyler's Avatar
      Join Date
      Apr 2008
      Gender
      Location
      North Carolina
      Posts
      1,587
      Likes
      36
      2 days away.
      Get posting Philosopher.
      This shit never happens to me

    8. #8
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by PhilosopherStoned View Post
      Is there a reason you felt the need to write it in shell script as opposed to python, perl or ruby?
      Cause I did the first stats scripts in bash, and a lot of the tricky stuff (like tracking scores through all the posts) was already done (so they just got recycled)

      Plus, I'm more proficient in bash
      I know the syntax for most of the standard unix utilities pretty much by heart

      I can do Perl, sort of....
      But if I did it in perl, I'd spend half my time looking up functions and things in the documentation, and it'd take me forever.

      I can rattle off bash scripts pretty much off the top of my head
      (\_ _/)
      (='.'=)
      (")_(")

    9. #9
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by Fableflame View Post
      OH!
      Now I understand!
      This is all automated?
      Yep,

      Code:
      cd ~/scripts/dv_elim_2
      ./elim_start
      (but it's setup as a cronjob on my server, so I don't even have to execute it manually)
      Run everyday at 04:20, 12:20, and 20:20
      Code:
      20 4,12,20 * * * /home/tony/scripts/dv_elim_2/elim_start
      (\_ _/)
      (='.'=)
      (")_(")

    10. #10
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      I can barely even understand what's going on. Bash is weird, I never got into it.

    11. #11
      Member Tyler's Avatar
      Join Date
      Apr 2008
      Gender
      Location
      North Carolina
      Posts
      1,587
      Likes
      36
      Fucking awesome.
      Way to go Ynot.
      This shit never happens to me

    12. #12
      Veteran of the DV Wars Man of Steel's Avatar
      Join Date
      Mar 2007
      LD Count
      ~35
      Gender
      Location
      Houston, TX
      Posts
      4,553
      Likes
      94
      Even though I know no bash to speak of, I can kinda see how it works, and it makes me want to learn shell scripting. Can't be harder than PHP. Actually, some of it looks similar.

      Awesome stuff, Tony. Thanks for putting so much time into this! Heh, I hope your server can handle the jump in bandwidth it's going to get once this thing starts up...

    13. #13
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      shell scripting is easy (no, I really do mean that)
      there's almost nothing to learn
      All a shell does is allow the user to run programs

      it's the unix utilities you need to know

      All bash does is allow you to have loops, conditional statements, etc. - all the flow control, basically

      all the function is provided by external programs
      (\_ _/)
      (='.'=)
      (")_(")

    14. #14
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      I mean seriously,
      how often do you use echo, grep, sed, etc. etc. on a daily basis
      me? many many times a day
      and I'm guessing power-users (I do hate that word) are the same

      I know that wget will download stuff over the internet

      wget has a few options, and I know this
      Code:
      wget -q -O - "http://www.dreamviews.com/community/showpost.php?p=1176274&postcount=13"
      will download the page in quotes, and dump the html to the standard output

      I know that grep can selectively print lines based on regex expressions
      Code:
      some_input | grep '<script'
      will only print the lines containing the phrase "<script"

      I know that wc can be used to count the number of lines in an input
      Code:
      some_input | wc -l
      will print the number of lines in some_input

      so, chain all the utilities together, you get....

      Code:
      wget -q -O - "http://www.dreamviews.com/community/showpost.php?p=1176274&postcount=13" | grep '<script' | wc -l
      which tells me that there are 7 script blocks in the html page
      (\_ _/)
      (='.'=)
      (")_(")

    15. #15
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Quote Originally Posted by Ynot View Post
      I mean seriously,
      how often do you use echo, grep, sed, etc. etc. on a daily basis
      I only even know what echo does

    16. #16
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      I think there might be some bug in the system that counts the votes. I and some others are registered to have voted an uneven number of times, which is not possible without a revenge vote.
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    17. #17
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by khh View Post
      I think there might be some bug in the system that counts the votes. I and some others are registered to have voted an uneven number of times, which is not possible without a revenge vote.
      You've got an odd number because there's a mistake in one of your votes

      here,
      http://www.dreamviews.com/community/...34#post1178034

      The guy before you, KingYoshi voted grasshoppa down to 9
      but this is not reflected in your votes (grasshoppa still on 10)

      Way too late to correct the mistake (it's on page 6 of 15), but there we are
      (\_ _/)
      (='.'=)
      (")_(")

    18. #18
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      Oh, that's strange. I copied that post directly from him. Perhaps it was a trailing error.

      Well, sorry for blaming your script then
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    19. #19
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by khh View Post
      Well, sorry for blaming your script then
      Christ, blame away - all programs have bugs

      Jeff and I had a good 3/4 PM's back & forth about errors in the stats - I believe I've squashed all them all, but I'm sure there's one or two corner cases I've missed
      It's just the nature of programming (especially programs that take variable input)
      (\_ _/)
      (='.'=)
      (")_(")

    20. #20
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      It's not working anymore
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    21. #21
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      what's not working?
      (\_ _/)
      (='.'=)
      (")_(")

    22. #22
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      The page. It hasn't been updated since november 26th.
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    23. #23
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      oops,
      typo in crontab....
      (\_ _/)
      (='.'=)
      (")_(")

    24. #24
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      Ah, well I figured it'd be something like that
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •