Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
LDJosh
Posts: 242
Joined: Fri Oct 26, 2007 6:07 pm UTC
Location: South Central, PA
Contact:

Coding: Fleeting Thoughts

Postby LDJosh » Wed Nov 07, 2007 6:30 pm UTC

OK. Looks like this board needs a fleeting thoughts thread. - Hammer

While testing some session data handlers, I passed an unset variable to php with the date/time format set. instead of an error, php gives me the 'beginning' of time. so according to php, time began on:

1969 12 31 19:00:00

december 31st, 1969 at 7pm sharp huh?

well let’s see when it will end. Launch outlook, go to tasks. enter a task (like live forever). in the due date, put “forever”.

Seems like time will end on:

Tue 8/31/4500

neat stuff, huh?
This is what I did at work today.
Last edited by Hammer on Wed Nov 07, 2007 6:36 pm UTC, edited 1 time in total.
Reason: Changed to Fleeting Thoughts
--------
~Lameduck Josh
ninjajosh.com

photosinensis
Posts: 163
Joined: Wed Aug 22, 2007 6:17 am UTC

Re: Coding: Fleeting Thoughts

Postby photosinensis » Wed Nov 07, 2007 10:08 pm UTC

While adding two randomly generated integer matrices of size 16834 * 16834:

"Damn, this is taking a long time."

I looked, and sure enough, I was doing a crapload of disk swapping. Too bad I've only got 2 GB of memory on that machine. The code didn't finish running before I had to pack up the laptop and run, though.
While I clicked my fav'rite bookmark, suddenly there came a warning,
And my heart was filled with mournng, mourning for my dear amour.
"'Tis not possible!" I uttered, "Give me back my free hardcore!"
Quoth the server: 404.

Workaphobia
Posts: 121
Joined: Thu Jan 25, 2007 12:21 am UTC

Re: Coding: Fleeting Thoughts

Postby Workaphobia » Wed Nov 07, 2007 10:12 pm UTC

The Unix Epoch is the starting point for many integral time representations, and it is defined to be midnight, January 1st, 1970. Your time was exactly 5 hours earlier, so I take it you're on the East Coast.

Fun fact #1: This time representation doesn't map one-to-one to real seconds, because every now and then it has to adjust with a leapsecond or some similar approximation. It's close enough for almost all purposes.

Fun fact #2: Systems that use a 32-bit signed integer to represent the time can only count forward 2,147,483,647 seconds (68 years), after which they will overflow at the "end of time". This is sometimes known as the Y2.038K problem.

As a Computer Science major, I am logically (not!) required to take Intro to Biology. Some of the people in that class had no concept of magnitude and got the Earth's age confused with numbers like how long ago the dinosaurs became extinct. To illustrate the point that the difference in magnitude between one million and one billion actually mattered, the teacher asked us how long 2 billion seconds is. This is probably the only time my interests helped me in that class.

Sidenote: is a "fleeting thoughts" thread not supposed to have responses to a particular topic, or do multiple discussions just get multiplexed in here?
Evidently, the key to understanding recursion is to begin by understanding recursion.

The rest is easy.

User avatar
Kizyr
Posts: 2070
Joined: Wed Nov 15, 2006 4:16 am UTC
Location: Virginia
Contact:

Re: Coding: Fleeting Thoughts

Postby Kizyr » Wed Nov 07, 2007 10:30 pm UTC

Workaphobia wrote:The Unix Epoch is the starting point for many integral time representations, and it is defined to be midnight, January 1st, 1970. Your time was exactly 5 hours earlier, so I take it you're on the East Coast.

When I saw the first post, the only thing that stood out as unusual was the fact that it was at 19:00 and not midnight on January 1st, 1970.

My fleeting thought from coding... I'm starting to think that opposition to COBOL began primarily because THE CODE IS SCREAMING ALL THE TIME. KF
~Kaiser
Image

User avatar
Hammer
Because all of you look like nails.
Posts: 5491
Joined: Thu May 03, 2007 7:32 pm UTC
Contact:

Re: Coding: Fleeting Thoughts

Postby Hammer » Thu Nov 08, 2007 12:05 am UTC

Workaphobia wrote:Sidenote: is a "fleeting thoughts" thread not supposed to have responses to a particular topic, or do multiple discussions just get multiplexed in here?

It's for posts that don't really need a dedicated thread of their own. Responses are fine. If something actually coalesces into a topic, I'll split it.
"What's wrong with you mathematicians? Cake is never a problem."

User avatar
evilbeanfiend
Posts: 2650
Joined: Tue Mar 13, 2007 7:05 am UTC
Location: the old world

Re: Coding: Fleeting Thoughts

Postby evilbeanfiend » Fri Nov 09, 2007 10:44 am UTC

iirc the second before the unix epoch starts is used as an error value
in ur beanz makin u eveel

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: Coding: Fleeting Thoughts

Postby Sc4Freak » Sat Nov 10, 2007 3:44 am UTC

evilbeanfiend wrote:iirc the second before the unix epoch starts is used as an error value

Which would be a value of -1, I believe. Makes sense.

User avatar
fryman
Posts: 50
Joined: Mon Aug 20, 2007 7:11 pm UTC
Location: In a box, sitting next to a cat.

Re: Coding: Fleeting Thoughts

Postby fryman » Sat Nov 10, 2007 5:51 am UTC

Using CLargeNumber, I wrote a program to calculate the fibonacci sequence up to whatever, giving options for output to file/console, output all values, etc. The 1,000,000th Fibonacci number is 208988 digits in length. I forgot to check how much CPU time it took, but it took quite a while (after 300,000 iterations I was running at about 80/sec). I'm still fiddling with gcc switches to see if I can speed it up a bit.
Open source sigs? Here, use mine!

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: Coding: Fleeting Thoughts

Postby mrkite » Sat Nov 10, 2007 7:05 am UTC

fryman wrote:Using CLargeNumber, I wrote a program to calculate the fibonacci sequence up to whatever


I don't know anything about CLargeNumber, but the "standard" bignum library for C is GMP, which also proclaims to be the fastest.

So you might be able to speed up your code by using it instead...

User avatar
M.qrius
Rainbow Brite
Posts: 519
Joined: Sat Nov 10, 2007 12:54 am UTC
Location: Rainbow's end
Contact:

Re: Coding: Fleeting Thoughts

Postby M.qrius » Sat Nov 10, 2007 4:11 pm UTC

Code: Select all

boolean ever = true;
for(;ever;) {
    [Do stuff]
}


Nice way to write down an eternal loop :P

unmoored
Posts: 6
Joined: Wed Sep 05, 2007 3:32 pm UTC
Location: Linkoping, Sweden
Contact:

Re: Coding: Fleeting Thoughts

Postby unmoored » Sat Nov 10, 2007 5:47 pm UTC

M.qrius wrote:

Code: Select all

boolean ever = true;
for(;ever;) {
    [Do stuff]
}


Nice way to write down an eternal loop :P


Code: Select all

#define ever ;;

for(ever)
{
}

User avatar
M.qrius
Rainbow Brite
Posts: 519
Joined: Sat Nov 10, 2007 12:54 am UTC
Location: Rainbow's end
Contact:

Re: Coding: Fleeting Thoughts

Postby M.qrius » Sat Nov 10, 2007 6:20 pm UTC

unmoored wrote:

Code: Select all

#define ever ;;

for(ever)
{
}

Nice :D
There's some "until hell freezes over" around here somewhere as well... but the only language I know with until is TI-Basic.

User avatar
Sastira
Posts: 19
Joined: Sat Nov 10, 2007 3:09 am UTC

Re: Coding: Fleeting Thoughts

Postby Sastira » Sat Nov 10, 2007 8:17 pm UTC

My favorite way to teach C newbies about why they should free() their malloc()s:

Code: Select all

while(malloc(1024));
Making days is easy if you know the right recipe.

EvanED
Posts: 4324
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Sat Nov 10, 2007 11:02 pm UTC

Sastira wrote:My favorite way to teach C newbies about why they should free() their malloc()s:

Code: Select all

while(malloc(1024));

Raymond Chen collected a bunch of entries from his blog The Old New Thing, expanded some of them, and put them in a book. The book has a couple bonus chapters that are available online, one of which is this big long thing that is half a rant against programs that were written poorly -- pretty much that assumed that they were not running in protected mode or in a multitasking environment -- and half a description of things programmers should do to make their programs compatible with Windows 95 without making MS hack around their bugs for them. (One of Chen's main roles for Win95 was application compatibility -- figuring out what are essentially hacks MS could put into Windows to allow buggy programs to continue to operate. Apparently there's a fairly famous one with SimCity 2000 where they had to do something to compensate for it accessing memory that had been freed.)

There is an entire section, beginning on page 17, called "allocate available memory". It includes such examples (in approximate order of increasing ridiculousness) from real-world applications and games as

Code: Select all

while ((dwMem = DPMI_QueryFree()) != 0) {
    AddToHeap(DPMI_Allocate(dwMem), dwMem);
}

and

Code: Select all

for (dwMem = 0x1000000; dwMem; dwMem -= 0x1000) {
    while ((hmem = DPMI_Allocate(dwMem)) != 0) {
        AddToHeap(hmem, dwMem);
    }
}

and

Code: Select all

again:
for (dwMem = dwLinFree; dwMem > 0; dwMem -= 0x8000) {
    if ((hmem = DPMI_Allocate(dwMem)) != 0) {
        AddToHeap(hmem, dwMem);
        goto again;
    }
}


The whole chapter is well-worth reading, because it's absolutely hilarious.

User avatar
Sastira
Posts: 19
Joined: Sat Nov 10, 2007 3:09 am UTC

Re: Coding: Fleeting Thoughts

Postby Sastira » Sun Nov 11, 2007 8:51 pm UTC

That just made my headache worse. Ouch. ;)

I'll have to give that a looksee! Thanks EvanED!
Making days is easy if you know the right recipe.

User avatar
fryman
Posts: 50
Joined: Mon Aug 20, 2007 7:11 pm UTC
Location: In a box, sitting next to a cat.

Re: Coding: Fleeting Thoughts

Postby fryman » Mon Nov 12, 2007 6:24 pm UTC

mrkite wrote:I don't know anything about CLargeNumber, but the "standard" bignum library for C is GMP, which also proclaims to be the fastest.

So you might be able to speed up your code by using it instead...


I wrote this in C++, but GMP claims compatibility... I suppose I could branch off and re-write it using GMP. And a GUI with a timer would be a nice addition as well. I also noticed the hard division between Intel and AMD, being stronger at maths and graphics respectively.
Open source sigs? Here, use mine!

User avatar
LDJosh
Posts: 242
Joined: Fri Oct 26, 2007 6:07 pm UTC
Location: South Central, PA
Contact:

Could you explain programming please?

Postby LDJosh » Thu Dec 20, 2007 8:06 pm UTC

From thedailyWTF forums:

Being a programmer and the only computer literate person in my family, I get tech support calls from my family all the time. I got a phonecall from a brother-in-law today:

Him: Hey, you're good with computers right?

Me: Yes.

Him: And you know how to program computers?

Me: Yes, thats my job actually.

Him: Could you explain programming please?

Me: I'm sorry, what do you mean?

Him: I want to make a game like Halo, but I don't know how to start. Could you explain what I need to do?

Me: You should probably go to the library and get a book.

Him: Can you just tell me what I need to do?

Me: Wait a minute. Are you asking me to explain how to program computers?

Him: Yeah.

Me: Over the phone?

Him: Yeah.



My brother in law apparently made several unsuccessful attempt to "learn programming" by opening up exes in Notepad. He created a text file with the words "Morph the screen into something cool" and couldn't figure out how to run it, even had the balls to ask me "how do I install my program? Do I just put a shortcut on the desttop".

My dad, a programmer, lent him an unfortunately titled book called "Teach Yourself Java in 24 hours". He immediately flipped to the back of the book and reading sections on server and Swing development, and was very excited to see that he could write his own server after just one day.

In the end, I was unable to teach my brother in law how to make his own Halo over the phone, and he decided that I wasn't a very good programmer.
--------
~Lameduck Josh
ninjajosh.com

User avatar
segmentation fault
Posts: 1770
Joined: Wed Dec 05, 2007 4:10 pm UTC
Location: Nu Jersey
Contact:

Re: Could you explain programming please?

Postby segmentation fault » Thu Dec 20, 2007 8:40 pm UTC

its simply telling the computer what to do in a language the computer can understand. it is also a very deep rabbit hole. if youre interested in programming simply because you want to make a game like halo, youre better off not caring how halo was made and just sitting back and enjoying the game.
people are like LDL cholesterol for the internet

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Mon Dec 31, 2007 9:47 am UTC

I wonder how sad and alone this poor little thread I just wrote must feel, since she's wait()ing and all of her little thread friends died before ever notify()ing her.
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
LoopQuantumGravity
Posts: 416
Joined: Mon Oct 01, 2007 4:19 am UTC

Re: Coding: Fleeting Thoughts

Postby LoopQuantumGravity » Mon Dec 31, 2007 12:39 pm UTC

EvanED wrote:a rant against programs that were written poorly


Another program from Publisher 31 allocates all the memory it can, and each time you start
a new mission, it zeroes out everything.

Program 24b first allocates all the memory in the system into a “spare pool.” When it needs
to allocate memory from the pool, it first attempts to grow the spare pool; if this succeeds,
the application crashes. (How could I possibly make this up?) Otherwise, it shrinks the spare
pool by the amount it wants to allocate, then allocates the desired value. If this second
allocation fails, the application crashes.

I... I... I just don't know what to say...

But the next time I hear someone complain about Windows, I will make them read (and understand) that entire chapter before they're allowed to talk to me again!
I study theoretical physics & strings, and am a recipient of the prestigious Jayne Cobb Hero of Canton award.

And the science gets done and you make a neat gun
For the people who are still alive!

User avatar
niteice
Posts: 186
Joined: Wed May 02, 2007 4:17 am UTC
Contact:

Re: Coding: Fleeting Thoughts

Postby niteice » Tue Jan 01, 2008 12:33 am UTC

EvanED wrote:a rant against programs that were written poorly


I'm pretty sure Example 43 is SimCity 2000 for DOS. I had an older machine with 64MB of RAM, so I tried to play...curiously, it only warned me, instead of actually stopping me from continuing. I think hope it was just an overflow.
GENERATION 4294967292: The first time you see this, copy it into your sig on any forum, negate the generation, and convert it to a 32-bit unsigned integer. Social experiment.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Tue Jan 01, 2008 12:41 am UTC

FT: I like threads, but I feel maybe they should be used for other things than making a bunch of threads calculating primes, pi, factorials etc. while still allowing me to use the python interpreter in the meantime, which I only use to poll the other threads to see how far they've come anyway.

Oh, wait, I did use it for something useful once. I had to factorize a bajillion numbers, so I made a thread to do that for me while I wrote the rest of the program. Well, useful... the thread finished in less than a second, but THE IDEA WAS SOUND at least.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

der_bAUer
Posts: 74
Joined: Wed Nov 01, 2006 9:55 am UTC

Re: Coding: Fleeting Thoughts

Postby der_bAUer » Thu Jan 03, 2008 4:26 pm UTC

During the past week or so, I had my seventh or so go at programming some sort of personal information manager modeled after David Allen's book "Getting Things Done". The six designs before died of spaghetti code and other sources of non-maintainability, so this time I decided to make everything really modular. And I would make it a service oriented architecture, even though I don't know anything about how to design or implement one. Oh, and learning XMLRPC (or how to use python's xmlrpc module) is too complicated and requires me to register my functions with the RPC server, so I rolled my own "dead simple minimalistic remote procedure calls" (dsmrpc). Oh, and someday I might write a service in another programming language (always wanted to have an excuse to learn Scheme, Haskell, C, C++), so I can't just send pickled objects over the network, so I programmed my own serialization functions, too.

Surprisingly, this has not become spaghetti code, and the first app build on top of this framework, a simple wiki, actually works. But it is slooow! Maybe doing 37 dsmrpc's for each page is a little too much, considering that a new connection is created for each request ;)

Guess I have to optimize the dsmrpc part so that it does not send data over the network when the function to be called lives in the same python process...

Whatever, so far it's been really fun, a good learning experience, and this promises to be extendable enough so that I won't start over from scratch again.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Coding: Fleeting Thoughts

Postby Berengal » Fri Jan 04, 2008 5:32 am UTC

I made pong!
But it needs a) Startup interface allowing you to select number of players and keymapping, b) AI, for those lonely nights and c) hot client on server multiplayer action
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Notch
Posts: 318
Joined: Tue Dec 12, 2006 5:52 pm UTC
Location: Stockholm, Sweden
Contact:

Re: Coding: Fleeting Thoughts

Postby Notch » Fri Jan 04, 2008 10:53 am UTC

Berengal wrote:c) hot client on server multiplayer action


Good luck! High latency pong is a very interesting problem.

User avatar
crazyjimbo
Posts: 887
Joined: Fri Apr 20, 2007 11:45 pm UTC
Location: Durham, England
Contact:

Re: Coding: Fleeting Thoughts

Postby crazyjimbo » Fri Jan 04, 2008 11:29 am UTC

Notch wrote:Good luck! High latency pong is a very interesting problem.


Are you talking about pong ping?

Notch
Posts: 318
Joined: Tue Dec 12, 2006 5:52 pm UTC
Location: Stockholm, Sweden
Contact:

Re: Coding: Fleeting Thoughts

Postby Notch » Fri Jan 04, 2008 1:50 pm UTC

crazyjimbo wrote:pong ping?


.. !

Well played! =D

arcoain
Posts: 56
Joined: Thu Dec 20, 2007 12:34 am UTC

Re: Coding: Fleeting Thoughts

Postby arcoain » Sun Jan 06, 2008 4:59 pm UTC

nah man I'm talking about
pong pong pong pong Server Time Out Warning ping ping ping 0x45035 Exception

rodarmor
Posts: 1
Joined: Sat Mar 08, 2008 11:33 am UTC

Declarative Programming

Postby rodarmor » Sat Mar 08, 2008 11:58 am UTC

"What's declarative programming?" she asked sweetly.

"Well," he began, moving closer to her, "declarative programming is when you tell the computer what you want, and then the computer figures out how to get it. Pretty sweet, huh?"

"What kinds of things can you tell the computer you want?" she asked, her cheeks beginning to flush.

He thought for a moment, and began stroking her hair gently. "All kinds of things. There's a language called prolog you can use to ask about logical expressions. In SQL you can ask about relationships between data. With a program like bison you can use declarative programming to describe a language, letting bison generate something that recognizes it."

"Oh," she said breathlessly, leaning her head on his shoulder, "so I don't have to worry about choosing an algorithm--the computer will pick one for me?"

He silently began caressing her breasts.

She took this as an affirmation. "That's so cool that it just does it--it must be really smart to pick the right algorithm!" she enthused.

"Well..." he trailed off, still gently fondling her breasts.

"What?" She asked, suddenly nervous.

"Um..." he said, "it's not quite like that." His hand stopped moving.

She sensed he was backpedaling. "Well?" She demanded.

He laughed awkwardly. "Heh... You see, most declarative programming systems only know about one algori--"

"It must be a great algorithm!" She interrupted, with renewed intellectual arousal. "What is it?"

He hesitated for as long as he could... "Brute force search," he said, guiltily.

"What the fuck!?!?" She yelled, straightening and yanking his hand from her breast.

"Wait, baby, it's not so bad!" He begged.

"I'm listening." She said, looking him in the eye.

"Well, if you're careful and you program in an idiomatic way, you ca--"

A venomous glare silenced him mid-sentence. She stood suddenly, grabbing his hat from the night stand and moving towards an open window.

"My Stetson!" He shrieked, standing quickly. The spurs on his cowboy boots jangled feebly. "But baby, didn't that bison parser generator thing sound cool?" He pleaded.

She stopped. "Well... yeah, that was pretty neat..." she begrudgingly acknowledged, softening for a moment.

"And that doesn't use a brute force algorithm. It builds an automata for you, an LR parser," he said.

She smiled to herself, seeming to relent momentarily. He could see that she was touched by the idea of a program that could understand other programs.

"See, declarative programming isn't all bad..." he cajoled, slowly walking towards her, palms outstretched.

She started, as if waking from a dream. She looked at him. "But what about in the case of an ambiguous grammar, for which an LR parser won't suffice?"

"Don't worry," he said, smiling, "bison can use a technique called generalized LR parsing, which allows it to follow all possible parses simultaneously, eventually finding a successful parse."

She thought for a moment. "But if we're following all possible paths simultaneously and discarding the ones which don't lead to successful parses, isn't that just brute force search?!?" She asked, her voice suddenly ringing with betrayal.

Her words were damming. Nothing he could say would placate her. He stood in embarrassed silence, eyeing his cowboy hat nervously.

She turned away from him, her emotions halfway between pity and rage. He moved towards her, reaching for her hands, but it was too late. She had already hurled his hat from the window, as hard as she could. They watched silently as it flew through the night, lofted on the cool air as if by the breath of angels.

User avatar
Spoffin
Posts: 509
Joined: Mon Nov 26, 2007 12:51 am UTC

Re: Declarative Programming

Postby Spoffin » Sat Mar 08, 2008 1:52 pm UTC

Funneh!!!

:lol:
The thing to remember about Spoffin is that he's playing by rules no one else understands

User avatar
thoughtfully
Posts: 2243
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: Coding: Fleeting Thoughts

Postby thoughtfully » Sat Mar 08, 2008 6:59 pm UTC

Definitely need a Hall of Shame just for this shining example of not reading the fora rules. Wow.

I'm not sure which rule you feel this violates. It was originally a separate thread. I dropped it into this Fleeting Thoughts thread as it seemed pretty fleeting. There was the possibility that some people would find it funny. - Hammer

Sorry. I thought it was a "shining example" and a "post which didn't follow the rules". (not posting in the intro thread) I enjoyed it very much, and thought it more insightful/touching than humorous. If there was a place of posts that were outside the usual rules, this would be an interesting one to find there.

Just FYI: We are no longer requiring a post in the Intro thread. This version of phpBB has much improved spammer protections.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

ObsidianX
Posts: 3
Joined: Thu Mar 20, 2008 12:59 am UTC

Sandwich

Postby ObsidianX » Thu Mar 20, 2008 1:07 am UTC

Last edited by ObsidianX on Thu Mar 20, 2008 3:26 am UTC, edited 1 time in total.

phildini
Posts: 1
Joined: Thu Mar 20, 2008 1:11 am UTC

Re: Sandwich

Postby phildini » Thu Mar 20, 2008 1:13 am UTC

Heh. Multi-lingual webcomic hacks. yummy.

User avatar
Magilla
Posts: 478
Joined: Wed Mar 19, 2008 11:28 pm UTC
Location: Esperance, Western Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby Magilla » Thu Mar 20, 2008 2:29 am UTC

I was at work til 8:30* last night fighting with asp. My fleeting thought was "holy crap, vbscript sucks!"

Even when it's well written, it's difficult to read. I wonder if I can convince the boss that jscript is better...





* I'm supposed to finish at 5...
They perceive my perambulations upon my gyroscopically-balanced personal transportation device, and have thus concluded that I am of Caucasian decent, and, while intelligent, I am also somewhat socially inept. - Peculiar Alfred

ObsidianX
Posts: 3
Joined: Thu Mar 20, 2008 12:59 am UTC

Re: Coding: Fleeting Thoughts

Postby ObsidianX » Thu Mar 20, 2008 3:19 am UTC

Ack! I'm sorry I didn't read the rules! >.<

coppro
Posts: 117
Joined: Mon Feb 04, 2008 6:04 am UTC

Re: Sandwich

Postby coppro » Thu Mar 20, 2008 3:25 am UTC

ObsidianX wrote:I got bored... decided to code http://xkcd.org/149/ in a few languages:
One nitpick - what if user account 0 isn't named root? (Note: I wonder if naming your root account something else would help guard against exploits?)

Karrion
Posts: 92
Joined: Fri Jun 22, 2007 12:14 am UTC
Location: Melbourne, AU

Re: Sandwich

Postby Karrion » Thu Mar 20, 2008 3:45 am UTC

coppro wrote:
ObsidianX wrote:I got bored... decided to code http://xkcd.org/149/ in a few languages:
One nitpick - what if user account 0 isn't named root? (Note: I wonder if naming your root account something else would help guard against exploits?)


Linux Administration Handbook wrote:Linux does not prevent you from changing the username on [the root] account, or from creating additional accounts whose UIDs are 0, but both are bad ideas. Such changes have a tendency to create inadvertant breaches of system security.

--Linux Administration Handbook By Evi Nemeth, Garth Snyder, Trent R. Hein, section 3.2

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Mon Mar 24, 2008 8:00 am UTC

Sometimes I wish someone would write quick reference cards for different languages syntaxes. It's quite annoying to have a language that you know, but don't write often enough to do the syntax by reflex 100% of the time. For example, I am primarily a Java and C# programmer, and I could write those with my goddamn eyes closed. But it inevitably comes to pass that PHP or VB is the only way a given employer is going to let me do anything. I made PHP very, very angry a few dozen times today with simple syntax errors (why is it "if($variable)" but "include '$variable'"?!?!??!)
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
Xanthir
My HERO!!!
Posts: 5198
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Mon Mar 24, 2008 12:53 pm UTC

wing wrote:Sometimes I wish someone would write quick reference cards for different languages syntaxes. It's quite annoying to have a language that you know, but don't write often enough to do the syntax by reflex 100% of the time. For example, I am primarily a Java and C# programmer, and I could write those with my goddamn eyes closed. But it inevitably comes to pass that PHP or VB is the only way a given employer is going to let me do anything. I made PHP very, very angry a few dozen times today with simple syntax errors (why is it "if($variable)" but "include '$variable'"?!?!??!)

Um, it's not. You can uses parenthesis with an include() or require() as you wish - it's entirely optional. If you have the pathname in a variable, you don't need quotes either.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: Coding: Fleeting Thoughts

Postby wing » Mon Mar 24, 2008 2:53 pm UTC

Xanthir wrote:
wing wrote:Sometimes I wish someone would write quick reference cards for different languages syntaxes. It's quite annoying to have a language that you know, but don't write often enough to do the syntax by reflex 100% of the time. For example, I am primarily a Java and C# programmer, and I could write those with my goddamn eyes closed. But it inevitably comes to pass that PHP or VB is the only way a given employer is going to let me do anything. I made PHP very, very angry a few dozen times today with simple syntax errors (why is it "if($variable)" but "include '$variable'"?!?!??!)

Um, it's not. You can uses parenthesis with an include() or require() as you wish - it's entirely optional. If you have the pathname in a variable, you don't need quotes either.

Okay, leave it to me to get it backwards at 4AM.

Why is "include '$variable'" valid and "if '$variable'" invalid? Now if you go ahead and tell me I'm wrong there, than I have an axe to grind with a certain pain in the ass webhosting company. (Their database creation control panel forces you to set what it considers a strong password... Which phpmyadmin - the ONLY available database frontend - will not accept because it's useless developers don't understand escaping)
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 8 guests