Comment On Stupid Coding Tricks: A Batch of Pi

It's high time for the second installment of stupid coding tricks! As we learned from the T-SQL Mandelbrot, a stupid coding trick isn't really about obfuscation per se... just, well, stupid awesomeness. Kinda like a quine, except even more useless. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:16 • by JimmyVile (unregistered)
I think it's neat, there have been quite a few occasions that I took on the challenge of writing things with batch files that no sane person should.

Nothing as cool as this though.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:24 • by Otto
... I can't explain why, but that code makes me want to punch something very, very hard.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:28 • by Beavis (unregistered)
242690 in reply to 242686
... I can't explain why, but that code makes me want to punch something very, very hard.


Are you like, angry at numbers, or something?

There's like, way too many of them.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:28 • by Someone (unregistered)
3.14159th comment.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:30 • by EFH (unregistered)
Wow.

Just... wow.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:31 • by Rev. Creflo Baller (unregistered)
Hats off to the coder, brilliant work!

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:34 • by Zygo (unregistered)
That batch script...almost makes we want to install the software necessary to run it.

Almost.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:36 • by Zygo (unregistered)
242696 in reply to 242695
That script also apparently makes me use the grapefruit words sometimes.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:41 • by The New WTF (unregistered)
I have, in my long life, seen very few examples of working so hard to have everyone ask.. "Why The F?"

I am amazed and nauseated at the same time. Bravo.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:42 • by Mr B
me:
running out of actual, funny new content?


Running out of actual, funny comments?

I like reading stuff like that, it's still a WTF (of the re-inventing the wheel/using inappropriate technology genre) but it's a clever and deliberate WTF so worthy of closer inspection.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:45 • by Trevel (unregistered)
Way back when taking a computer course, we were all supposed to write a tutorial on some random part of computing. I was assigned batch files for some reason.

Naturally, I wrote it as a batch file. (Excepting a small program I threw together to make up for the lack of any input-commands in DOS at the time.) Compared to the 'program' I'd written to pull things in and out of archive to save space on our 10M hard drive at home, it was pretty simple.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:46 • by panzi (unregistered)
Did somebody say quine? I once wrote 3 quines: Two bilingual (c+python and c+ruby) and one in xhtml+javascript.
http://twoday.tuwien.ac.at/pub/stories/311724/
:P

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:55 • by Eric Lyna (unregistered)
You're a geek, Don. That's why I like working with you.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:57 • by Anonymous Coward (unregistered)
The real WTF is that this batch file fails to calculate pi = 4*arctan(1)

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 09:58 • by nrq (unregistered)
That batch file is not DOSBox compatible.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:01 • by JHunz (unregistered)
242705 in reply to 242704
nrq:
That batch file is not DOSBox compatible.

Because...it's a Windows batch file?

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:03 • by Don Cross (unregistered)
242706 in reply to 242703
The reason I use these complicated formulas is because the series expansion for arctan(1) takes forever to converge (try it in a spreadsheet).

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:05 • by Anon (unregistered)
It's just gone 10 o'clock (am) and that is the most awesome thing I've seen today...so far.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:09 • by Polestar (unregistered)
Writing DOS batch files makes baby Jesus cry.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:10 • by jimlangrunner
242709 in reply to 242694
Rev. Creflo Baller:
Hats off to the coder, brilliant work!
I think that should be
Hats off to the coder, brillant work!
to fit in with the general them.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:12 • by ajlb (unregistered)
I once saw Perl master Damian Conway give a presentation called "Fun With Dead Languages" where he calculated Pi using POSTSCRIPT. It's actually turing-complete.

The output looked really nice, though.

He also, if I recall correctly, calculated primes using a parser for LATIN. He supposedly has another parser for Klingon, but it hasn't been approved by the Klingon Language Institute, and you don't want to get on their bad side.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:15 • by Mithfindel
I have a nice Windows batch implementation of an integer-only Vorbis decoder but the margin is too small to include it.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:16 • by J.R. Blood (unregistered)
I LOVE batch files, and this one just rocks.

I still prefer using batch for simple things, like... oh mapping drive letters to network shares. You can do it in one line and it's simple.

NET USE T: "\\SERVER1\Team Design"

Ever do it in a VBScript file?
(NOTE: Copy-n-paste from someone else's VBS file, including the typo in the server name.)

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "t:", "\\sever1\team design\"

Job security by complexity. There's a WTF for ya.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:24 • by evilspoons
I wrote a batch file front end for MP4Box for my specific task of losslessly cropping M4A files then renaming them - it would've been reinventing the wheel had YAMB not started crashing and freaking out on me, but it turns out I actually saved a lot of time by doing a FOR loop through my entire folder of hundreds of files.

Answering the wrong question

2009-02-06 10:30 • by DaveK
The OP:
so... now I can do... err....what?

Well, now I can finally answer that question.
Well, that give us the 'what', but you failed to answer the bigger question: WHY, in the name of all that's holy, why?

(Also, "How long, oh Lord?" might be relevant here.)

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:30 • by Batchyx (unregistered)
Man, Win32 Batch files is for pussies. Real Men use MS-DOS/win98 batches, which comes without blocks nor even ''integer support''

if you want integers, you need to implement them.
here's how you may implement the syracuse sequence :
http://pastebin.com/m3ee81f4c

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:32 • by Franky (unregistered)
242718 in reply to 242714
Wait, how is that example of VBScript more "complex" than NET USE? Sure VB forces you to create an object to get at the networking functions, but the alternative would be to have 1000 global functions like PHP4. Is that really any better? And is "NET USE" really any easier to understand then MapNetworkDrive?

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:34 • by Joey (unregistered)
Aww, dang. I really need to get my batch bignum library working some day. I did a few things worth mentioning in batch but also, nothing as cool as calculating Pi. Not yet, though :)

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:36 • by pitchingchris
242720 in reply to 242714
J.R. Blood:
I LOVE batch files, and this one just rocks.

I still prefer using batch for simple things, like... oh mapping drive letters to network shares. You can do it in one line and it's simple.

NET USE T: "\\SERVER1\Team Design"

Ever do it in a VBScript file?
(NOTE: Copy-n-paste from someone else's VBS file, including the typo in the server name.)

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "t:", "\\sever1\team design\"

Job security by complexity. There's a WTF for ya.



I don't agree with your assessment because of what it represents. net use is calling some code to do the work, underneath the scenes, there are many more lines of code that execute. You can't go by the fact that you only call 1 line that its any better. I can wrap up something into a console app, and the code behind it is much more intensive, and you'd never know the difference.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:44 • by Mike D. (unregistered)
242723 in reply to 242711
I remember Don Lancaster going on and on in column after column about how he did all his computing on his printer. He had some really cheap computer whose sole job was to download PostScript to his fancy printer. Now he uses Distiller to save paper.

http://www.tinaja.com/post01.asp

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:45 • by Rehevkor (unregistered)
"...the technology works well foa shortcut for typing in a bunch of commands."

Apparently it's also effective for cocking up sentences.

Here's what I tokoa way from it:

2009-02-06 10:55 • by brouski (unregistered)
AR_K! AR_K!

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 10:57 • by Anonymous (unregistered)
Well that was... pointless. Which is exactly what a stupid coding trick should be, so well done!

Re: Here's what I tokoa way from it:

2009-02-06 10:58 • by brouski (unregistered)
242727 in reply to 242725
My god, I type like I've got two raccoons by the tail and I'm swinging them onto the keyboard

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:01 • by AdT (unregistered)
242728 in reply to 242703
Anonymous Coward:
The real WTF is that this batch file fails to calculate pi = 4*arctan(1)


Yes, calculating a power series with x=1 is a brillant idea.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:10 • by Scott (unregistered)
The real WTF is everyone praising this code that uses a ton of GOTO commands...

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:23 • by ... (unregistered)
242733 in reply to 242720
"I don't agree with your assessment because of what it represents." - Been reading dilbert?

Maybe it's just good because it's quicker to type... 'and you'd never know the difference.'

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:27 • by hatterson
242734 in reply to 242730
Scott:
The real WTF is everyone praising this code that uses a ton of GOTO commands...


Uhhhh....this is a batch file. use of GOTO is perfectly fine.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:32 • by Butthead (unregistered)
242735 in reply to 242690
Wow. I thought I was the only one who remembered and laughed at insignificant lines from B&B.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:46 • by Scott (unregistered)
242739 in reply to 242734
I'm not knocking the code at all, and understand the need of them in batch files. It's just amusing.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:47 • by Scott (unregistered)
242740 in reply to 242734
Oops, hit reply instead of quote.. :(

hatterson:
Scott:
The real WTF is everyone praising this code that uses a ton of GOTO commands...


Uhhhh....this is a batch file. use of GOTO is perfectly fine.


I'm not knocking the code at all, and understand the need of them in batch files. It's just amusing.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:50 • by Smash King
242741 in reply to 242730
Scott:
The real WTF is everyone praising this code that uses a ton of GOTO commands...
Care to tell us how to do flow control and loops in a batch file without them, please?

Addendum: I posted together with your explanation, and I can't delete.

Re: Here's what I tokoa way from it:

2009-02-06 11:53 • by abstract protected synchronized final void longSignature() (unregistered)
242743 in reply to 242727
brouski:
My god, I type like I've got two raccoons by the tail and I'm swinging them onto the keyboard


I have patent pending on that input method; You owe me royalties! Oh wait, you only type 'like' my method. Now how can I charge for that....

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:53 • by pjt33
242744 in reply to 242741
Smash King:
Scott:
The real WTF is everyone praising this code that uses a ton of GOTO commands...
Care to tell us how to do flow control and loops in a batch file without them, please?

Recursion.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:57 • by Smyle (unregistered)
242745 in reply to 242714
J.R. Blood:
(NOTE: Copy-n-paste from someone else's VBS file, including the typo in the server name.)

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "t:", "\\sever1\team design\"


Not to mention that it wouldn't work anyway. The trailing '\' makes the command blow up. Don't ask me how much time it took me to figure this out.

Robust but fast VBscript to map drives here that I stole just last week.

CAPTCHA: nulla - the amount of information I'm contributing to this discussion.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 11:59 • by Smash King
242746 in reply to 242744
pjt33:
Smash King:
Care to tell us how to do flow control and loops in a batch file without them, please?
Recursion.
Recursion could do as loops, but not as flow control (IFs) . And as far as I remember you need some sort of flow control to prevent your recursive calls going to the infinite.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 12:15 • by Zost (unregistered)
SINE! COSINE! COSINE! SINE!
Three-point-one-four-one-five-nine!

GO PI!

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 12:16 • by freespace (unregistered)
242748 in reply to 242728
The infinite series expansion of arctan is not a power series, and there is nothing wrong with expanding a power series with x=1 either, provided it converges for x=1.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 12:20 • by pjt33
242749 in reply to 242746
Smash King:
pjt33:
Smash King:
Care to tell us how to do flow control and loops in a batch file without them, please?
Recursion.
Recursion could do as loops, but not as flow control (IFs) . And as far as I remember you need some sort of flow control to prevent your recursive calls going to the infinite.

The "them" was GOTO statements. You don't need GOTO statements to use IF statements.

Re: Stupid Coding Tricks: A Batch of Pi

2009-02-06 12:26 • by Alin (unregistered)
242750 in reply to 242694
Rev. Creflo Baller:
Hats off to the coder, brilliant work!


More like "brillant" work!
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment