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
Vanadium
Jan 8, 2005

The code in a finally block gets executed whether an exception is thrown or not. This does neither apply to regular blocks nor to catch blocks, so this is important.

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

It is also faster if your standard library implementor decides to implement .size() in O(n) :colbert:

csammis, C++/CLI has finally, by the way. :)

Vanadium
Jan 8, 2005

Nice you see that you guys are almost catching up to C++, and your syntax is only minimally clumsier too!

Edit: They should codename C# 4.0 "playing catchup"

Vanadium
Jan 8, 2005

What is the proper way to send and receive messages to a multicast group over all network interfaces, instead of just the default one? Apparently it vaguely works if I create one socket per interface and specify the interface index explicitly when I join the multicast group, but that seems a bit unnecessary. Somehow default routes keep getting in my way. :(

Vanadium
Jan 8, 2005

Scaevolus posted:

What happens when you pipe a line with more than 100 characters into this program? Foo is only defined to be 100 characters, so you end up writing to other memory. This is a buffer overflow, and you need to beware of them when you write C.

What you should be doing is
while (fgets(foo,100,0) != NULL) {

At least he does not instantly get a segfault from passing null pointers as streams.

Vanadium
Jan 8, 2005

chocojosh posted:

1) The standard of using only up to 80 columns seems to be quite outdated. I had a prof who actually took off marks for this. My monitor supports up to 140 columns (visual studio 2003) at the default font and 1280*1024 resolution. Now, I know different people use different text editors, different font sizes, and so on, but could we please update the standard to 120/130? And then actually ENFORCE it so that I don't have to read stored procedures with lines of 200+ characters.

No, mail software still breaks at ~80 characters and terminals and consoles and whatever are still 80 characters in width. :shobon:

Vanadium
Jan 8, 2005

Factor Mystic posted:

On the other hand, I for one would rather sit down and start coding instead of memorizing command line tools and other crap that stand between the program in my mind and the program-to-be on the computer.

I for one would rather sit down and start coding instead of memorizing Visual Studio stuff that stands between the program in my mind and the program-to-be on the computer. :colbert:

Vanadium
Jan 8, 2005

Neslepaks posted:

You can't really get confused by Scheme vs Common Lisp. Scheme is so small that you've quickly got a good grasp of it, and then you just have to learn the differences and the rest is CL.

Is that not about the naive C vs C++ assumption?

Vanadium
Jan 8, 2005

bijou posted:

Does anyone know why I cant get in to #cobol using my favorite IRC client, mibbit.com??

10:44 -!- 1 - #cobol: ban *!*@synIRC-F5376B42.mibbit.com [by rocketsauce, 14847 secs ago]

Vanadium
Jan 8, 2005

So set B1, B2 to =A2-A1, =A3-A2 and so on and average through that?

Vanadium
Jan 8, 2005

They have different scoping rules, too.

Vanadium
Jan 8, 2005

Quick and easy solutions are the best kind of solutions.

Vanadium
Jan 8, 2005

Scaevolus posted:

v:shobon:v
The lower level equivalent would be C, not ugly python code :colbert:

bitprophet posted:

For what it's worth, some languages let you do this on the fly, although I don't remember the technical term for it (I believe there was one).

In C++, for example:

int a = 25, b = 50, c = 75, d = 100;
boost::tie(a, b, c, d) = boost::make_tuple(b, c, d, a);

Vanadium fucked around with this message at 18:37 on Aug 24, 2008

Vanadium
Jan 8, 2005

Works fine, you should probably say what you are trying to do.

Vanadium
Jan 8, 2005

Well, it literally puts text into the DOM and not whatever nodes that would parse to. Because it is text and not magical html code.

Just manually create the elements and plug them into the tree yourself. :colbert:

There are some people who would suggest you use some sort of abomination like .innerHTML but that is clearly non-standard and thus unportable and also heresy. Also you would run into escaping issues if you did it like that.

Vanadium
Jan 8, 2005

Can you implement cond with a macro, without using if or whatever? :colbert:

Vanadium
Jan 8, 2005

GT_Onizuka posted:

ps: lisp rules :colbert: :coal:

Now if only someone would take all the cool features and put them into a useful language. :c00lbert:

Vanadium
Jan 8, 2005

Just convert the string into a long by ORing together the individual chars, then you can switch on the long and then you get O(1) instead of O(96) wait no

Vanadium
Jan 8, 2005

Just put every output string into a separate file with input string as the name, then your function can just open it and read out the result and you do not have to switch or anything.

Vanadium
Jan 8, 2005

Can you not just use LINQ or something in this case

code:
var query =
  from pair in new string[][] { 
    new string[] {"ABC", "DEF"}, 
    new string[] {"GHI", "JKL"},
    ...
  }
  where pair[0] == key
  select pair[1];
foreach (string result in query) {
  return result;
} 
    
return null;
vvv when in rome...

Vanadium fucked around with this message at 01:33 on Sep 19, 2008

Vanadium
Jan 8, 2005

Also the escaping rules for non-perl regexes are going to drive you mad.




:doom:

Vanadium
Jan 8, 2005

Stephen posted:

My site displays a user's webpage that they've specified in their account info. When they type in a full URL (http://www.example.com) it works perfectly, but when they type in a partial URL (www.example.com), the link directs to http://www.mypage.com/www.example.com.

That is not a partial URL, that is just a host name. Just tell your users to gently caress off until they have learned to write URLs! :mad:

Vanadium fucked around with this message at 19:14 on Jun 7, 2014

Vanadium
Jan 8, 2005

If your webpage is delivered by anything but http, you do not deserve to get linked to anyway. :mad:

Vanadium
Jan 8, 2005

Nahrix posted:

Oh, sorry. To clarify, I just want to user to type something in and hit enter.

Replace EOF with '\n'?

Vanadium
Jan 8, 2005

ante posted:

If you want character at a time, you can use getch and kbhit. My idiot programming teacher has a hardon for them.

Pft, nonstandard functions are cheating.

Vanadium
Jan 8, 2005

Krimlander posted:

Secondly, does anyone know of a few good templates for something like this?

You should ask in the webcomics thread in BSS.

Vanadium
Jan 8, 2005

Works for me too. There is a general .NET thread.

You are not splitting this up into multiple files, are you?

Vanadium
Jan 8, 2005

Welp, I just figured it might have to do with the package visibility thing, but I am not sure how that works because I am not in fact a .NET developer, so I just pasted everything together and then it worked.

Edit: I am using mono

Vanadium
Jan 8, 2005

This depends on what kind of access you have to your web server. Running stuff periodically sounds like a cronjob, but if you just have webhosting, you probably cannot do that, or really do anything beyond responding to http requests.

Vanadium
Jan 8, 2005

Bodhi Tea posted:

I'm not 100% sure if I can do cronjobs, but there is a section in cPanel labeled cronjobs. If I were able to do that, say I wanted to run a php script foo.php, would I just set the cronjob command to "php foo.php" ?

Commandline php might run in a different environment if it is available at all than apache's mod_php, but it might work. :) I have no experience with cpanel, so just try it.

Vanadium
Jan 8, 2005

Clock Explosion posted:

In Haskell, let's say I have a list of coordinate pairs, and am interested in deleting anything that has a first of 4, while I don't care what the second value is.

You will probably want to use filter, as in filter ((/=) 4 . fst) yourList.

Vanadium
Jan 8, 2005

rjmccall posted:

Haskell lets you write (/= 4), and it does what you think.

How is ((/= 4) . fst) better than ((/=) 4 . fst)?

Vanadium
Jan 8, 2005

XMLHttpRequest, and some more asynchronicity than you are using right now?

Vanadium
Jan 8, 2005

Turkmenbashi posted:

dumb MATLAB Q: I'm trying create a set of vectors which includes every possible combination of 1 and 0 in the n elements of the vector.
Would you not just count up to 2^n, and then set the elements of the current vector to 1 that correspond to the bits that are set in the counter?

I have no clue about MATLAB so this might very well be a stupid idea.

Vanadium
Jan 8, 2005

Did you try method="post"?

Vanadium
Jan 8, 2005

nbv4 posted:

code:
for(field in fields) {
		
	$("#button_" + field).click(function(event) {
		
		if( $("#id_" + field).val() == "") {
			$("#id_" + field).val($("#id_total").val());
		} else {
			$("#id_" + field).val("");
		}
	});
}
How can I get this little javascript code to work. The problem has to do with variable scope, I'm sure. Basically I want to create a bunch of jQuery objects through a loop.

The problem is that field refers to the last object in all callbacks, right? I think you can workaround that by having the variable enclosed in the callback function come from another function's scope:

code:
var make_callback = function(field) {
  return function(event) {
    if( $("#id_" + field).val() == "") {
      $("#id_" + field).val($("#id_total").val());
    } else {
      $("#id_" + field).val("");
    }
  }
}

for(field in fields) {
  $("#button_" + field).click(make_callback(field))
}

Vanadium
Jan 8, 2005

My intuition says you have so say "global foo" in the subfuction, but I never used matlab, sorry. I am not an engineer. :(

Vanadium
Jan 8, 2005

quadreb posted:

If the drive doesn't exist on my computer, why would it be linked like that?

The compiler just stored the path to the source file with the debugging symbols. Why should it care whether you happen to have a drive with the same name?

Vanadium
Jan 8, 2005

Maybe, but I have seen it happen with a bunch of commercial applications.

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

jamal jenkins posted:

My question: Is there a way to parse a webpage before I view it in order to rearrange the elements the way I'd like? Perhaps with a greasemonkey script? For example, look at the SA forums page. Is there a relatively simple way to change which forum is at the top? I can take care of the coding aspect if you can point me into the right direction.

Greasemonkey can do that, but it will only run your script on the page after it has finished loading. If you need it earlier, you would need to use some proxy gadget like mousehole.

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