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
csammis
Aug 26, 2003

Mental Institution
Goodness the old one had been going a long time

A Paradigm Shift: This thread is now for generic questions about coding, and language-neutral short programming questions (or languages for which there isn't already a megathread). If you've got a question about a specific language, and there's a megathread for it, better to post it there where the language-specific dorks experts will see it.

:siren: THE MEGATHREADS :siren:

Apple App Development: iOS (iPhones and iPads), Mac OS X, Xcode, Cocoa

C/C++ Programming Questions Not Worth Their Own Thread

Cavern Reading List - Recommend and Request reading material

Flash Questions Megathread

Java questions which don't deserve their own thread, yet.

Game Development Megathread

Want to Learn Haskell?

.Net (C#, VB.NET [VB 2003, 2005, and 2008]) Questions Megathread

The Perl Short Questions Megathread: executable line noise

<?PHP questions that don\\'t need their own thread ?>

Python information and short questions megathread.

Ruby on Rails Love-In

Scientific/Math(s) Computing: numerical/statistical analysis tools and CASs - R, Matlab, etc.

SELECT * FROM Questions WHERE Type = 'Stupid'

Version Control Questions Megathread (SVN / git / whatever else)

Web Design/Development Small Questions - Rev Holy Grail

Small Excel Question Not Worth Its Own Thread

If I missed one, or a new one appears, PM me to get it listed here


:siren: HOT GOON ACTION :siren:

Now you too can chat with real life nerds, 24/7 because we don't have lives or sleep! Join the CoCs at #cobol on irc.synirc.net, we are happy to answer your questions while mocking you and randomly replacing words with "butt."

Don't like talking to or looking directly at nerds but want to gain their power, just like Highlander?! Check out http://sn.printf.net/, the CoC goon blog aggregator. Read more about it here, right here

csammis fucked around with this message at 15:01 on Aug 16, 2016

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution
Let's get this party started:

Jose Cuervo posted:

poopiehead, do you know of a good way to search for a particular key in a dictionary without actually knowing the key, but only a unique characteristic? I know that the key I am looking for is the one the has the longest string length (and there is a key with a longest string length in my dictionary). Right now I am useing the following loop to get the key:
code:
         For Each key As String In myDic.Keys
            If key.Length > theLongestKey.Length Then
               theLongestKey = key
            End If
         Next
where I initially have theLongestKey set as an empty string. This works, but I thought there might be a cleverer (and hopefully more efficient) way to do it.

Note, this is a good example of a question that belongs in this thread because it's language-agnostic :)


Iterating through the keys to find what you're looking for is the only way to do it at any given time, unless you want to use a "compiler solution" and throw another list at it that consists the keys sorted by the property you want, which you would add to whenever you insert a new key into the dictionary. I can't really imagine that there's a good reason to do this.

But along those lines: Wherever you're adding an entry to the dictionary, how about you just add a check to see if the key that's being added satisfies the property you want, and save it?

csammis
Aug 26, 2003

Mental Institution

Professor Science posted:

Oh that series that people have on their bookshelf so they can be like, "Oh, yes, I've read the Art of Computer Programming, yessssss, I am smoking a pipe now?"

Has this man read TAOCP? :raise:

csammis
Aug 26, 2003

Mental Institution

Mister Biff posted:

Edit: Er, this may be more appropriate for the C/C++ thread... if so, just tell me.

Yes, either that or the .NET thread (as you're working with Visual Studio), but try the C/C++ thread first.

csammis
Aug 26, 2003

Mental Institution

Kaiju posted:

I have a client at work that has two mirror sites translated into German and Spanish. All three sites are hosted on the same server. The translated sites are relatively new and since they launched, they've started having submissions to their contact forms that include non-english characters. When the form outputs the submission emails anything not english, say, letters with accents, umlauts or tilde (for spanish characters) they are replaced in the email body with strange approximations and not the correct characters.

And if it matters, the sites are all in ASP classic.

I've never had to deal with anything like this in the past and I'm not sure how to fix it. I've been letting this one slide for a while and people are starting to ask questions.

Any ideas?

"Text encoding" is the keyword you'll be looking for, as that's the problem. The users are sending characters to the web server in a character set that your email can't contain, probably because your email is sending as ASCII. You'll have to send the emails using the correct text encoding, whatever that might be. I think it'll be whatever encoding the form's page is being sent in, but I'm not sure. The web development thread folks might know right off the bat.

csammis
Aug 26, 2003

Mental Institution

Dog Named Duke posted:

A C# question

For the future: .Net (C#, VB.NET) Questions Megathread

csammis
Aug 26, 2003

Mental Institution

Appa Time! posted:

code:
if(mylist==null)
{
	return mylist;
}

An empty list isn't null in Java, it's just empty. size() == 0.

csammis
Aug 26, 2003

Mental Institution

dougdrums posted:

So I was :420: (not now, earlier) and programming and thinking about the finally statement. Is there any god drat reason for the finally statement? The only situation I see using finally in is if I didn't want to put a catch statement after a try which is a horrible practice anyways. And even if I did want to do that, couldn't I just use catch { } instead?

Sorry if I'm retarded and there actually is a good use for finally and I just never figured it out.

Edit: C#.

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.

http://neptune.netcomp.monash.edu.au/JavaHelp/howto/try_catch_finally.htm#whyFinally

csammis
Aug 26, 2003

Mental Institution

Milde posted:

Newer versions of Python have a nicer syntax for that:
code:
with open('/dev/null') as f:
    # do some stuff
No need for the explicitly finally/close, the with statement sets it up so f.__exit__ is always called, which simply calls close() (and this __enter__/__exit__ protocol can be adapted to other kinds of classes, like database cursors, thread locks, etc.)

For posterity, C# has this too in the using keyword:
code:
using(FileReader reader = new FileReader("C:\\myfile.exe"))
{
  // read read read
}
// When execution leaves the using block, the FileReader is closed and disposed of
The lock keyword works on the same principle.

csammis
Aug 26, 2003

Mental Institution

tef posted:

Aside: I'm tempted to write a FAQ but really the only frequent question is "WHat Language should I learn?"

And the answer is "don't bother asking because you won't listen anyway" :smith:

csammis
Aug 26, 2003

Mental Institution

karuna posted:

Just did a quick search there and it seems control arrays are no longer supported, I'm using visual basic 2008 express edition..
Would you know of any other way i can refer to the labels with a variable?

Cheers

VB 2008 is .NET, please refer to the .NET Questions Megathread. You may be able to use reflection to access the labels.

csammis
Aug 26, 2003

Mental Institution

Careful Drums posted:

In Assembly, I need to print out the string

"The sum of the integers is"

And after hauling rear end doing messed up packed binary addition in Assembly, I can't do this WAAGH HALP

What kind of assembly? What architecture? Are you using a library, or pure assembly code?

csammis
Aug 26, 2003

Mental Institution
:siren: Adding a link to the Cavern Reading List in the OP :siren:

csammis
Aug 26, 2003

Mental Institution

MEAT TREAT posted:

What about something like Dominoes and we each have to create a client that has to beat the rest.

Wrong thread :ssh:

csammis
Aug 26, 2003

Mental Institution

astr0man posted:

I've been looking into writing a vista sidebar IM client using libpurple (gaim/pidgin/finch libraries) but I wasn't sure if it would even be possible. The IM interface would be in C++. I know you can execute C++ code with a DHTML interface, but I don't have enough experience with DHTML to know if something of this magnitude would be possible. So any suggestions as far as the best way to go about doing this or a pointer to some good reference material would be appreciated. Or just shoot the idea down if it's not feasible.

libpurple is probably ridiculously heavyweight for a sidebar IM application...it's basically an entire backend framework that implementors provide a frontend to (see: Adium). This is something of a design flaw with libpurple in my opinion, because using it isn't as simple as calling a function with a message and the screen name you want to send to.

That said, I really have no idea how you could go about interfacing with libpurple from DHTML in the first place. If you're not set on C++, and you can use something like Script#, you could leverage .NET solutions for instant messaging libraries (such as OscarLib, MsnLib, and JabberLib :v: ).

Disclaimer: I have never tried to make a sidebar application, or used Script#, but I do know a lot about IM applications in general. If you'd like any information on that end please feel free to ask.

csammis
Aug 26, 2003

Mental Institution

Blacknose posted:

When using Eclipse to code java I know there is a way to make it automaticaly insert stubs for javadoc comments, but I can't for the life of me find out how. Anyone know if it's an add-on or pre-installed, and how to use it? Can't find anything useful on google.

When you're using the wizard to create a new object, there's a checkbox for "Generate Javadoc comments" or something like that. I didn't add any plugins to get that behavior.

Also, you can put your cursor on the member in question and hit Shift-Alt-J to get Javadoc automatically inserted in the same manner Rheingold mentioned.

And finally, you're looking for the Java megathread :ssh:

csammis
Aug 26, 2003

Mental Institution

Presa Canario posted:



It doesn't look like you're ever popping from leaves, is that correct?

edit: It's been a while since I've done this, but wouldn't a stack-based DFS look more like this? A single stack, no leaves.

code:
Stack<Node> s = new Stack<Node>();
s.push(GetTreeRoot());
while(s.size() > 0)
{
  Node current = s.pop();
  // Process current node
  if(current.HasChildren)
  {
    // Push all children onto s so they get visited
  }
}

GT_Onizuka posted:

It would probably be better to store the depth of nodes, along with the nodes themselves, so you don't have to handle any incrementing.

This too, I think the depth calculation is where you're getting messed up.

csammis fucked around with this message at 18:34 on Mar 28, 2008

csammis
Aug 26, 2003

Mental Institution
I mean seriously it's not like we have Perl or Python or Ruby threads so people can decide for themselves what they should use :rolleye:

csammis
Aug 26, 2003

Mental Institution

NotAok posted:

I've been able to successfully load these by just using the assembly class, but I used the easier LoadFile method. This method may be what's tripping me up here.

Yup. Read up on Fusion to understand the semantics of how and where the Framework will look for an assembly to load using the Load() methods vs. LoadFile(). Also, make sure that the DLL's you're loading are valid .NET Assemblies, because I seriously doubt twain_32.dll is .NET :)

edit: Also, the .NET Megathread is where this question belongs

csammis
Aug 26, 2003

Mental Institution
The Web Development Megathread has some words about web development too. Maybe too many words? :raise:

csammis
Aug 26, 2003

Mental Institution
Check the book request / recommendation thread, or you can ask in the .NET Megathread for specific topics.

csammis
Aug 26, 2003

Mental Institution

This was the exact site I was thinking of to answer his question, but goddamn if I could remember the address and Googling wasn't helping :smith:

csammis
Aug 26, 2003

Mental Institution

6174 posted:

I couldn't remember it offhand either, but it was #2 for "file specifications" at Google.

Yeah yeah, I was looking for "image file formats"

csammis
Aug 26, 2003

Mental Institution

darfur posted:

I've searched the web for this, but can't really find a good answer.

What good is an interface? I understand what one is, and how I would implement one, but I don't understand the benefit of using one instead of just writing the classes that would use it by themselves without using the interface. It seems like if your class "inherits" and interface, it must include all of the methods in the interface, but why not just write the class with all the methods anyway?

Can anyone clarify this for me?

Hiding methods that consumers don't need to know about, for one. Here's a quick example of a really good reason to use an interface:

code:
public class SomeData
{
  public void setData(String data);
  public String getData();
}
But what if you don't want your consumers to set the data, because it's something done by your business logic only? Changing the visibility of the setData method won't cut it, because you still want to be able to set it, so you create an interface that only exposes the getData method:

code:
public interface IData
{
  public String getData();
}

public class SomeData implements IData
{
  public void setData(String data);
  public String getData();
}
Give your consumers IData objects instead of SomeData objects, and bam, safe encapsulation.

Another good reason is being able to change implementations under the hood without the consumer having to be aware of it. Let's say you have a connection class. Could be a connection to a database, could be a connection to a network socket, could be a connection to some dank nugz from the kid your parents warn you away from all the time, but all your consumer cares about is that it's a connection to some resource. If you give them a DatabaseConnection, they have to write new code when you decide that databases are stupid and you'd rather have them use a NetworkConnection. If these connections implement a common interface, however, the consumer won't have to change anything in order to get your data from a new source.

edit: continued, more formally and less contrived:

Interfaces are contracts: they guarantee that a class has methods X, Y, and Z. It doesn't specify how that contract will be fulfilled, that's the job of the class that implements the interface. Interfaces allow a programmer to separate the design (the interface) from the implementation (the class).

csammis fucked around with this message at 20:21 on May 7, 2008

csammis
Aug 26, 2003

Mental Institution

Incoherence posted:

Another example: event handlers. All event handlers for a given event implement the same interface, but they may (and hopefully do) have different behavior, and you may have multiple different event handlers for a particular event.

Huh? Event handlers (callbacks, whatever you call them in your language) are methods, not interfaces. The fact that you can have multiple event handlers for a single event has zilch to do with interfaces, it has to do with how events are implemented in your architecture.

csammis
Aug 26, 2003

Mental Institution

MEAT TREAT posted:

e: csammis where those methods come from? You have to inherit them from some place and in languages that don't allow multiple inheritance you have to use interfaces so that you can have multiple even handlers for one object. I think Incoherence said it wrong, I'm sure he meant that one object can have multiple even't handlers like keyboard and mouse, not that many objects can share the keyboard event handler. Because in that case you are correct, interfaces have nothing to do with it.

I know what Incoherence meant about one event having multiple handlers, but I'm not sure where you're coming from. Inheriting a method? :psyduck: Where are you inheriting the method from when you use a delegate in C#? How about registering a method callback in C++? Event handling is a concept that has absolutely nothing to do with interfaces. Interfaces only come into it as an implementation detail of Java's Listener pattern.

csammis
Aug 26, 2003

Mental Institution

Tomed2000 posted:

I don't know if this thread is the best place to ask this but:

What is the most common programming environment in the industry? By that I mean is it most common that you will be working in a Unix/Linux environment with some editor like Emacs are is it more common to have a Windows environment with something like Visual Studio?

Because every part of this industry uses the exact same tool for everything :eng99:

edit: Seriously what kind of question is that? In my last job, one tiny part of "the industry," we used three commercial IDEs and one proprietary, and then some people used other stuff if they wanted to / were allowed to.

csammis fucked around with this message at 19:20 on May 30, 2008

csammis
Aug 26, 2003

Mental Institution

Zombywuf posted:

Also, how do I stop smilies appearing in code blocks?

Check the "Disable smilies" box in your post

csammis
Aug 26, 2003

Mental Institution

Kino posted:

I've googled around a bit, but the only thing I can find is someone asking the question on experts-exchange where the usual google cache trick won't work.

Does the "scroll down past the interstitial ads until you see the answer" method work on that page?

csammis
Aug 26, 2003

Mental Institution

Counter Punch posted:

Any ideas? [on slowing down copy and paste speed]

Am I asking this in the wrong place?

Thanks...

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.

csammis
Aug 26, 2003

Mental Institution

Avenging Dentist posted:

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.

Yeah, sorry, I should've been more specific. There's no external way to slow down your basic inter-application clipboard reading or writing, like a registry setting or whatever. If you want to go completely nuts, you could do what AD suggested, but it's probably easier just to copy+paste smaller chunks.

csammis
Aug 26, 2003

Mental Institution

JoeNotCharles posted:

I'm not familiar with NetTerm, but it might be easy to write a small app in Python or something which just watches for anything copied to the clipboard, reads it all, and then writes it back to the clipboard in smaller chunks with a pause between each chunk. I'd use PyQt for this because the Qt clipboard API's pretty easy to use, but that's because I'm already familiar with it and I have it set up - the Windows clipboard API is easy to use to so a small VB script might be just as good.

You'd have to invoke Paste events on the NetTerm session as well.

csammis
Aug 26, 2003

Mental Institution

Daedalus256 posted:

I'm completely loving new at this so bare with me.

I need some code to stop a script from dying. Right now what I have is whenever you click on a button, the script launches whatever exe is specified. If you cancel that installation however the script gives an error and whatever else saying "Operation Canceled by User"

Is there some sort of easy vb I can throw into this so that doesn't happen?

No.




fake edit: probably, but we're not psychic. We'd need the code that is responsible for running the EXE at the very least.

csammis
Aug 26, 2003

Mental Institution
You assholes better not derail this thread, we've got like three dedicated to that already ~:mad:>

csammis
Aug 26, 2003

Mental Institution

Mr. Jive posted:

So how can I build a practical skill set? I'm just assuming that most of you have been through a similar phase, how did you bridge the gap between theory and practice?

I contributed to and managed open source projects. If you use any open source projects, try to find a feature that's irritating you and might be improved, or a new one that you'd like to see, and implement it. Most (many? some? only me?) OSS project managers would be happy to help you as long as you try to figure things out on your own. If you don't know of any projects you'd like to work on, look around on Sourceforge or ask CoC for their favorites.

csammis
Aug 26, 2003

Mental Institution

fletcher posted:

Kinda off topic, but why is the message board software they use on sourceforge so horrible?

Oh, who knows. I'm fairly sure it's all home-rolled and it's sucked as far back as I can remember, even after their revamp a couple years ago. My projects lasted about three weeks with Sourceforge before I got completely fed up with it and moved on to another project host.

csammis
Aug 26, 2003

Mental Institution
For an API reference, probably your best bet would be to google for "msdn [name of your function or class]" - but a straight up list of what classic ASP has available, that I don't know.

csammis
Aug 26, 2003

Mental Institution

mnd posted:

What's the closest thing to Core Animation on Windows? In a quick look, it seems to be WPF, and some WPF-related links I've followed seem to indicate that WPF supports an implicit animation model like Core Animation (set start, end, and interval, and it figures out interpolation for you). It's probably less elegant than Core Animation, but is it functionally accurate?

Yeah, Windows Presentation Foundation is as close to Core Animation as it gets for the Windows platform. I've never used Core Animation so I can't speak to elegance in comparison, but WPF is pretty slick, and there's a thread about it if you have any questions while you're learning. Keep in mind WPF is only supported on Windows XP SP2 and up.

csammis
Aug 26, 2003

Mental Institution

mnd posted:

More simple .NET-related questions:

We have a megathread for .NET, please use it

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution
Evolutionary algorithms come up with extremely efficient solutions that often look batshit and inelegant compared to human designs. Take rotor's recently posted radio antenna, designed using an evolutionary algorithm.



edit: The thread in which rotor posted this

csammis fucked around with this message at 22:19 on Sep 3, 2008

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