Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

fret logic posted:

I'm just a CS freshman with little to no background in anything beyond basic Java/C syntax. Was just wanting to get some basic theory in my head while I'm learning these languages.

If you want some "deep" theory, check out Knuth's "Art of Computer Programming" series (be warned, they are very, very math-heavy).

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

fletcher posted:

Is it more common to write variables as someVariable or some_variable? I can't decide which to use. I like using someMethod() instead of some_method(), so I'm thinking it would make more sense to use some_variable.

Generally, I think it's best to pick one style and use it for both variables and methods. It just makes things more consistent.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

csammis posted:

This construct exists in Java too (does C++ have it?), and any introductory text on either language will tell you exactly what finally is for. It's not a replacement for a catch.

C++ doesn't have "finally" because you should be using RAII instead. :)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
You need to surround the regex with slashes, like you would in Perl.

Also why in god's name do you have a regex like that? I think when you have to worry about table breaking with a regex, you might want to look into writing a grammar to do whatever it is you're doing (possibly hard in Javascript unless there's a library for it). The benefit of a grammar is that it isn't write-only code. :)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

nbv4 posted:

gah, I have a habit of calling either back slashes or front slashes "backslashes". I tried adding front slashes and it gave me the "unterminated regular expression literal" error. Backslashes gave me a syntax error.

It works fine for me. You're doing the following right?
code:
var date_regex = /[i]blahblahblahblah[/i]/;
Also, is there any particular reason you're using a regex that's checking to see if the date is after October 14, 1582 (i.e. is a Gregorian date)? It's doing some other equally strange stuff too. (EDIT: looks like the other strange stuff is to allow for the multiple instances that nations switched from Julian to Gregorian date systems.) Why not just use a simple regex to extract the pieces of the date, create a new Date object and make sure it's valid?

Avenging Dentist fucked around with this message at 20:59 on Mar 4, 2008

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Get rid of the newlines in the regex (obviously don't do this in the post :)).

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Unless you want to use C++, the only way I can think of would be to use preprocessor macros. Something like
code:
#define CAR_FORMAT "%d/%d/%d/%d/%d/%d/%d/%d/%d/%d"
#define PRINT_CAR(car) (car).PlayerID,(car).PositionX,(car).PositionY, \
	(car).PositionZ,(car).VelocityX,(car).VelocityY,(car).VelocityZ, \
	(car).OrientationX,(car).OrientationY,(car).OrientationZ



printf("Here is my car: " CAR_FORMAT,PRINT_CAR(myCar));

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
What's the easiest way to go about making a toolbar button for the Windows Explorer? Creating a new toolbar is also an option, but probably overkill since I only want to add a single button.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

FigBug posted:

I don't think you can add a single button, you'll need to make a toolbar with only one button.

Tutorial here: http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx

Turns out that's a wrapper to an MFC object, but at least now I know what the MFC object is (and can do this in C++)!

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
You should probably have something to delimit the fields of the struct. You're munging all the numbers together.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Well, let's say you have a struct with two doubles: x and y. Using your method, here's what happens:
code:
point foo;
foo.x = 1.234;
foo.y = 5.678;
sprintf(buffer,"%le%le",foo.x,foo.y); // buffer is now "1.234005.67800"

...

point bar;
sscanf(buffer,"%le%le",&bar.x,&bar.y); // this won't work right because sscanf won't know where x ends and y begins!
Solution:
code:
sprintf(buffer,"%le %le",foo.x,foo.y);

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Generally speaking, exceptions should be for "exceptional" things. I'd say bad user input isn't all that exceptional, and it's probably better to validate explicitly. It really depends on your own preferences though.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I don't know sed, but in Perl, the following should work:
code:
$foo =~ s/(^-+|-+$)/"?" x length($1)/eg;
The "e" option specifies that the second half of the regex should be evaluated as code.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
This should probably help you play around with styles to get something you like: http://www.somacon.com/p141.php

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Does anyone in the world actually do web development exclusively in UNIX?

Also, have you seen http://www.code101.com/Code101/DisplayArticle.aspx?cid=67 ?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

nbv4 posted:

I do all my programing in Ubuntu. Every few days I'll load my stuff onto my laptop which runs XP too see how it looks, which is kind of a pain.

I came across that script debugger, but I'm not about to pay hundreds of dollars to buy Office, just for that one tiny application.

I pasted the wrong link originally. I edited my post above to the right one. I'm still confused as to why you think there should be a way to debug Javascript in Internet Explorer in Linux of all things, though...

Why not just run a Windows VM?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Sartak posted:

Of course. Firebug is godly.

That's fine if you're developing for a single browser.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Zombywuf posted:

ORLY

That doesn't resolve the "IE Javascript debugging in Linux" issue, which is kinda the point. At the very least, you should be doing a pass of your site within Windows, and if there are problems, sometimes you have to suck it up and use Windows to have access to decent development tools for IE (unless you can get them working in WINE).

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
When you pipe commands, the piped data comes in via STDIN.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
There is none. It's just an alternative syntax.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
This? http://thedailywtf.com/Articles/Coding-Like-the-Tour-de-France.aspx

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

Looks like that was done by hand, not by a tool.

That still means it was done by a tool though. :pwn:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Jam2 posted:

What is the best web scripting language/framework to have my website developed using? php, .net, cf, ruby?

You can make a good website in any language, though PHP practically encourages insecure code, and ColdFusion has fallen out of style. Other languages to consider would be Perl and Python.

Jam2 posted:

What will be the easiest for a new programmer to interpret and add functionality to?

Probably PHP, but chances are that the code will have security vulnerabilities. Most programmers should be able to adapt to any OO language, and if they can't, chances are the stuff they'd have written would have been trash anyway.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
That's because you're not able to do it in C#.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

csammis posted:

Sorry, but it's not possible. Clipboard data is read by the application in one large chunk, and it's up to the application to process it however it's going to do it.

Actually, it depends on the storage medium used by the clipboard data. For something like Excel data, it's probably stored in global memory, so you'd be out of luck there, but it's totally possible to pass an IStream interface as the storage medium, and you could put in arbitrary delays when reading from the stream.

This would be a pretty complicated task and would require the terminal to support reading from an IStream interface, though.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Waltzing Along posted:

They favor the wiki because it is free. Management is learning of its limitations but likes the price.

Well, you get what you pay for...

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Mr. Jive posted:

The other day I scanned through rentacoder to see if I could apply my skills and earn some money, and realized how ridiculously small and inadequate my actual skill set is. I'm looking at an internship, but I'm hesitant to schedule an interview as I'm nervous about my ability to perform the job well. The list goes on.

Rentacoder is the shittiest poo poo that was ever shat from a butt.

Just make Tetris or something. It's better to try and fail than to sit around worrying whether you'll be able to finish a project. Honestly, I've learned the most from my aborted projects.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Does SetCursor work?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Magicmat posted:

:words:

I'm pretty sure Greasemonkey stuff runs once the DOM is loaded (or later). Also, I've never been able to figure out how to use Greasemonkey to look at/modify regular Javascript.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Also those aren't even arrays, they're objects.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I don't think you quite understand how arrays work. If you have a 2-dimensional array in Javascript, printing my2DArray[0] is going to give you something like "(Object Array)". You're making this way harder on yourself than you need to, though. Here's how I'd do it (not tested):

code:
var str = "2/3/08 12:00 AM|10/1/08 12:00 AM|10/12/08 12:00 AM";
var pieces = str.split("|");

var importantDates = [];
for(var i=0; i<12; i++)
    importantDates[i] = [];

for(var i=0; i<pieces.length; i++)
{
    var matches = pieces[i].match(/^(\d+)\/(\d+)/);
    if(matches) // if matches is null, the regex above failed for some reason
    {
        // this is more explicit than I'd normally be
        var month = matches[1];
        var day   = matches[2];
        importantDates[month-1].push(day);
    }
}
Note that foo = []; is shorthand for creating a new array.

Given the input I supplied, you'd get the following:
code:
importantDates[ 0 /*Jan*/] = []
importantDates[ 1 /*Feb*/] = [3]
importantDates[ 2 /*Mar*/] = []
importantDates[ 3 /*Apr*/] = []
importantDates[ 4 /*May*/] = []
importantDates[ 5 /*Jun*/] = []
importantDates[ 6 /*Jul*/] = []
importantDates[ 7 /*Aug*/] = []
importantDates[ 8 /*Sep*/] = []
importantDates[ 9 /*Oct*/] = [1,12]
importantDates[10 /*Nov*/] = []
importantDates[11 /*Dec*/] = []

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

N.Z.'s Champion posted:

Nope, serious, and I'm sure it's a stupid question (I'm pretty tired). Is there a way of doing it in a single expression?

Dude, someone showed how to do it like 5 posts up.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Jsquared posted:

code:
cout << "The average rainfall for ";
cout << str1;
cout << ", ";
cout << str2;
cout << ",and ";
cout << str3;
cout << " is ";
cout << averageRainfall; 
"inches"; // What

You're allowed to do all that in one statement. E.g. cout << foo << bar << baz << quux << endl;

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Plastic Jesus posted:

You can't re-use a pointer passed to realloc (that's why it returns a pointer) and your call to sprintf() could still overflow buff.

Also, this is very silly stuff. The dude asking the question isn't splitting the atom, he's creating a string. I have no idea why this is so confusing to people, but it scares the hell out of me to think that people get such basic things wrong.

This is a troll, right?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

A student posted:

Is python generally self-taught?

In that universities don't usually teach it, yes. Most everyone in CoC was probably self-taught at one point or another anyway. A university degree is really helpful to being the best programmer you can be, but it's by no means necessary.

To put things in perspective, a few of my friends are physicists, and when they need to learn a new language, someone just throws a reference manual at them and they figure it out.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
It's more math than computer science, but you might want to check out "Mathematical Models" by Richard Haberman. It's got a huge section on population dynamics, and it does a pretty good job of showing how you'd solve the differential equations using numerical (e.g. computer) methods.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Also if your problem is that the Fortran program is clunky, using C++ to call out to it isn't exactly going to resolve that. :geno:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I don't even know where to start. You're putting HTML in CSS files, using C-style comments in HTML, you're trying to import the CSS twice, and I'm not even sure what you're trying to do with the font styles.

I have a theory, and that theory is that the book you got isn't worth the paper it's printed on. Just use http://www.w3schools.com/ and save yourself the headache.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rjmccall posted:

Generally, no. In a compiled language, local variables are mostly an abstraction for expressing how data flows through a function, and using "extra" variables will often make absolutely no difference in the final code.

Sure it will. In most languages, local variables get pushed onto the call stack, so you'll be dealing with a (very) small but measurable cost to memory. Chances are you're not going to be losing much (if anything) in the way of speed, though.

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I was referring to the more general case of non-POD types with (not quite) equivalent code (C++):

code:
// 1
string foo = get_foo();
string bar = get_bar();
do_foo(foo);
do_bar(bar);


// 2
do_foo(get_foo());
do_bar(get_bar());

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply