Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Needs some PHP

Name: Anonymous 2010-07-03 7:48

I have some updating code, and I can't figure out how to remove the entry from the db if an error arises?


<?php

session_start();
require 'header.php';

?>
<?php

// Function for getting microtime in float (yes, from the PHP manual)
function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

// Produce error page if we are not logged in
if (!auth())
{

?>
  <div class="box">
   <div class="header">
    :: Need to log in ::
   </div>
   <div class="body">
    This does not work unless you are logged in
   </div>
  </div>

<?php

}
else
{
?>
  <div class="box">
   <div class="header">
    :: Mass update info ::
   </div>
   <div class="body">
    The following were updated during this tick:
    <br /><br />
    <table class="infotable" <?php echo $iefix; ?>>
     <tr><th>Character</th><th>Time</th><th>Status</th></tr>
<?php
    // Get list of names
    require 'database.php';
    $namelist = $highscores->get_names();
    $pertick = isset($_GET['count']) ? max(1, intval($_GET['count'])) : 5;
    $count = count($namelist);
    $pos = 0;
    $total_time = 0;
   
    if ($count > 0)
    {
        $name = isset($_GET['name']) ? $_GET['name'] : $namelist[0];
       
        // Check that the name really exists in the database
        if (($pos = array_search($name, $namelist)) === false)
        {
            trigger_error('Name not found in namelist!', E_USER_ERROR);
        }
    }
   
    for ($i = 0; $i < $pertick && $pos + $i < $count; $i++)
    {
        $error = false;
        $name = $namelist[$pos + $i];
        $cache = get_highscore_charcache($name);
       
        if (!$error)
        {
            $char = new rs_character($name, $cache);
           
            $timer = microtime_float();
            $error = !$char->load(false);
            $timer = microtime_float() - $timer;
            $total_time += $timer;
        }
       
        $upd = $error ? 'Failer' : 'Success';
       
        echo '     <tr>' .
            '<td class="left">' . display_rs_name($name) . '</td>' .
            '<td>' . round($timer, 2) . ' sec</td>' .
            '<td class="upd-' . $upd . '">' . $upd . '</td>' .
            '</tr>' . chr(10);
        flush();
    }   
?>
    </table>
    <br />
    <?php echo $i; ?> updated /
    <?php echo round($total_time, 2); ?> s /
    <?php echo @round($total_time / $i, 2); ?> s per char.
   </div>
  </div>
 
<?php if ($pos + $i == $count) { ?>
  <div class="box">
   <div class="header">
    :: Mass update finished ::
   </div>
   <div class="body">
    Mass updating has finished.
   </div>
  </div>
 
<?php } else { ?>
  <div class="box">
   <div class="header">
    :: Proceeding to next tick... ::
   </div>
   <div class="body">
    <a href="massupdate.php?name=<?php echo $namelist[$pos + $i]; ?>&count=<?php echo $pertick; ?>">Click
    here if you are not automatically forwarded</a>
   </div>
  </div>
 
<script type="text/javascript">
<!--
function forward(){
    location.href="massupdate.php?name=<?php echo $namelist[$pos + $i]; ?>&count=<?php echo $pertick; ?>";
}

setTimeout('forward()', 2000);
// -->
</script>
 
<?php
    }
}
?>

Name: Needs some Racket 2010-07-03 9:38

I have some factorial code, and I can't figure out how to extend the input domain to ℝ⁺?

#lang racket

(define (! n)
  (do ((a 1 (* a i))
       (i 2 (+ i 1)))
    ((> i n) a)))

(define (Γ n)
  (! (- n 1)))

Name: Anonymous 2010-07-03 11:21

>>2
(do
stopped reading right there

Name: Anonymous 2010-07-03 13:28

CODAN WAS WRITTEN BY XARN

Name: Anonymous 2010-07-03 13:44

Name: Anonymous 2010-07-03 13:49

I hate all these shitty PHP coders that are too bad to use any sort of framework--be it their own or others--that separates their stupid shit into any sort of feasible logic. Or at minimum separates PHP and HTML.

Name: Anonymous 2010-07-03 14:02

>>6
PHP was not designed to be separated from HTML.

Name: Anonymous 2010-07-03 14:07

>>7
To be fair, PHP wasn't designed at all.

Name: FrozenVoid 2010-07-03 14:07

PHP is the slowest language ever. You should rewrite it in C.

Name: Anonymous 2010-07-03 14:09

>>5
I don't think people who whine about the imaginary Xarn cult would enjoy his blog all that much. Or did you think >>4 was a genuine Xarn fan?

Name: Anonymous 2010-07-03 14:27

>>10
I don't really think anyone enjoys his blog all that much. Xarn doesn't present any new or interesting ideas through it; mostly it is just him recycling material he read about two days earlier in an /r/programming link. The fact he tries to teach other people these things when he could just post a link to a Wikipedia article, combined with the extremely condescending prose and wholly ignorant post titles- "Playing games is easy", to me it comes off as somewhat smug.

Name: Anonymous 2010-07-03 14:44

Xarn doesn't present any new
agreed

or interesting ideas
debatable

Name: Anonymous 2010-07-03 14:47

>>11
I've been waiting for this post. I can rest the Xarnbashing and Xarnbashingbashing now.

Name: Anonymous 2010-07-03 15:03

>>11
Well he's European, right?

Name: Anonymous 2010-07-03 15:36

>>11
he read about two days earlier in an /r/programming link
You know those links on /r/programming are links to his blog, right? Xarn famously hates Reddit, so I don't think he'd read one of its worst subreddits.

could just post a link to a Wikipedia article
Have you looked at the Wikipedia articles on the AI topics he discussed? His posts are a lot clearer and more informative.

wholly ignorant post titles
You don't even know what ``ignorant'' means.

Your criticism, if it applies at all, only applies to his AI post series. He posts more than that.

Name: Anonymous 2010-07-03 15:52

>>15
Fuck off, Xarn.

Name: Anonymous 2010-07-03 15:54

Another thread derailed by the Xarn bashers. Get your heads out of your asses, guys; if you ever did anything of merit you'd be /prog/ celebrity too.

Name: Anonymous 2010-07-03 15:57

I'm pretty sure that there's just one person that cares about the [b]Xa

Name: Anonymous 2010-07-03 15:58

HAX XARN'S ANUS

Name: Anonymous 2010-07-03 15:59

>>19
And so the two of /prog/'s plagues come together.

Name: Anonymous 2010-07-03 16:03

>>20
HMA and idiots trying to make Xarn look bad?

Name: Anonymous 2010-07-03 16:34

>>20
PLAGUE XARN'S ANUS

Name: Anonymous 2010-07-03 22:42

You know what I'm going to do? I'm not going to bold Xarn's name. It says on Rotahall that he's not a meme1. So, I'm going to reinforce that notion by not bolding. I invite anyone else to do the same.

1 I realize that bolding proper names is actually a more general meme, and one that does not specifically belong to Xarn; however, any sort of memetic, ritualistic behavior practiced alongside Xarn's name, especially when done often (as is the case on /prog/), associates the same image of tradition and collective worship that, when applied against a single person, is inappropriate to the spirit of these boards. In short: this behavior, while not specifically a Xarn meme, is making Xarn a meme. This needs to stop; even if it requires the sacrifice of yet another, seemingly unrelated meme. Who cares about memes, anyway? They're all stupid.

Name: Anonymous 2010-07-04 0:59

>>23
I don't think you even know what memes are, presumably because you came here from the imageboards.

Name: Anonymous 2010-07-04 1:08

>>24
I think those are pretty wild accusations, >>24-san.

Name: Anonymous 2010-07-04 1:19

>>23
Memes are shibboleths by which we distinguish the in-group from the out-group. In anonymous media, they're the only way to tell regulars from recent arrivals. This can become merely masturbatory (as it is on the imageboards), but /prog/ has a core of competent, intelligent regulars who actually have something useful to contribute, and is continuously awash in a sea of temporary morons, mostly from the imageboards; the cultural tradition enables us to construct a filter which enables us to enjoy /prog/ without wasting a whole lot of our time on the effluent.

Xarn is undoubtedly aware of this, and he's part of /prog/'s cultural heritage regardless. At this point he's as impossible to unseat as the /prog/snake and even the Sussman himself, because our memes never really go away. Your initiative serves no purpose other than to lower the threshold for ever more summerfriends, and to possibly get your own comments less attention than they would otherwise receive.

And in the end, Xarn isn't exactly harmful anyway. As a person he's one of the better /prog/ contributors, and as a meme, I'm not convinced the Xarn cult actually exists. He's just this guy we know, so obviously he's going to come up, same as MrVacBob and Taro and Christopher and Leah and Shii; that doesn't imply anything unscientific and ultimately destructive.
In fact, the most harmful Xarn-related activity on /prog/ nowadays is the Xarn bashers derailing threads, as happened here.

Just enjoy our shared culture. It's what makes us a community rather than just a programming help board.

Name: Anonymous 2010-07-04 4:51

The funny thing is that the Xarn lovers think they are any better than Xarn haters (well, they are, but now when it comes to keeping /prog/ clean).

Let me tell you a secret.

HOW TO FREE /prog/ OF THE XARN BULLSHIT
(by someone who does't give a fuck)
If you are a Xarn hater: Shut up. Stop making shitty bumps. Nobody gives a flying Philadelphia fuck. Go read xkcd or something.

If you are a Xarn defender: Shut up. Stop making "shitty" multi-line posts defending Xarn. Don't give a flying Philadelphia fuck. Go read Knuth or something.

Name: Anonymous 2010-12-23 9:56

Don't change these.
Name: Email:
Entire Thread Thread List