Today's programming silliness
And then creating a second function with 39 parameters to call the first one.
The worst part: I think it makes the code more readable!
$pathinfo = pathinfo($_FILES['file']['name'][$i]); $dest = $pathinfo['filename'] . strftime('-%Y%m%d-%H%M%S.') . $pathinfo['extension']; move_uploaded_file($_FILES['file']['tmp_name'][$i], $dest);
Eclipse is a maze of twisty build dependencies, all different. As best as I can tell there's the following:
It all seems massively overcomplicated when what's really needed is a way to list libraries/projects and mark them as either "build-time", "run-time", or both. Then when compiling it uses just the items listed as build-time, and when running or creating .WARs it uses everything listed as run-time and includes transitive run-time dependencies as well.
Okay, so it turns out that talismancer's post yesterday was filler. The moral balance has swung back!
As tempting as it is to fulfill the entirety of NaBloPoMo with us commenting on each other's posts, I feel like I should actually write something. So in the interests of increasing audience participation, I shall set a Java puzzler.
The puzzler consists of the following class:
import java.util.ArrayList; public class Foo { private ArrayList<Object> barList = new ArrayList<Object>(); public void fillBarList() { for (int i = 0; i < 10; i++) { Object o = new Object(); System.out.println("Adding " + o + " at index " + i); barList.add(o); } } public void emptyBarList() { for (Object o : barList) { System.out.println("Removing " + o); barList.remove(o); } } public static void main(String[] args) { Foo f = new Foo(); f.fillBarList(); f.emptyBarList(); } }
Without running it (because that would be cheating and you will be mocked for it), what do you think will happen when Foo.main() is called?
So, after 2 hours of writing some truely horrid Java code, I now have some shiny new comment stats from my shiny new LJ Stat-o-matic!
1 | ![]() | ![]() ![]() ![]() |
2 | ![]() | ![]() ![]() ![]() |
3 | ![]() | ![]() ![]() ![]() |
4 | ![]() | ![]() ![]() ![]() |
5 | ![]() | ![]() ![]() ![]() |
6 | ![]() | ![]() ![]() ![]() |
7 | ![]() | ![]() ![]() ![]() |
8 | ![]() | ![]() ![]() ![]() |
9 | Anonymous | ![]() ![]() ![]() |
10 | ![]() | ![]() ![]() ![]() |
Total Commenters: 79
Total Comments: 1676 (not including 148 deleted and 3 screened)
Report generated Sun Nov 06 23:14:41 GMT 2011 by boggyb's LJ Stat-o-matic 1.0 (inspired by
scrapdog's LJ Comment Wizard)
Credit where credit's due: scrapdog's original LJ Comment wizard is the inspiration for the tool and the result formatting, although I've ended up with a different calculation for the bars (his looks logarithmic, but I couldn't be bothered to do that and just made mine linear).
The other major difference with my stats is that I've excluded deleted and screened comments from the results. This has demoted Anonymous to #9 and restored olego to his rightful place at #2.
Source code is available if you want to run it yourself, but be warned - as said above, it was thrown together rather quickly over a couple of hours and doesn't contain a single comment!
Something a colleague came up with at work the other day...
Consider the following Java classes:
public class FooBase {}; public class Foo extends FooBase {}; public class Bar { public Bar(FooBase) { System.out.println("Constructor Bar(FooBase) called"); } public Bar(Foo f) { System.out.println("Constructor Bar(Foo) called"); } } public class Test { public static void testSomething() { java.util.ArrayList<FooBase> list = new ArrayList<FooBase>(); list.add(new Foo()); FooBase item = list.get(0); Bar b = new Bar(item); } }
Without compiling and running the program (because that would be too easy a way to solve this), what do you think will happen when you call Test.testSomething()?
My guess is that it will print "Constructor Bar(Foo) called", because while item is a reference of type FooBase the object being pointed to by item is actually of type Foo. But then the guy who came up with this pointed out that the output "Constructor Bar(FooBase) called" would also make sense, and if this were C++ that would be the expected output. The difference is all C++ knows is that it has a pointer to something that must be a FooBase, while Java knows that it has a pointer to something that is actually a Foo.
Of all the fun things to encounter with Visual Basic 6:
"Unexpected error occured in code generator or linker. --View error messages?" Yes/No/Help
*Yes*
( Wide error message )I didn't think it was possible to generate an internal compiler error in VB.
Edit: okay, I think I've worked out what line is killing it. Unfortuantly, this line of code basically reads "MyControl.Data = GiganticVariableSizeByteArray", and is a rather critical line for that control to work. I may have to abandon that idea of mine. The compiler appears to dislike moving large byte arrays around.