Search found 3024 matches

by Berengal
Sun Mar 27, 2011 11:38 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

RedditGameJam 06. Look for Samurai Showdown. Many other games are good too.
by Berengal
Sat Mar 26, 2011 10:58 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

You, sir, name? wrote:Good news, everyone! The new C++ standard is const.

FTFY. "final" is a Java keyword. In C++ it's "const".
by Berengal
Fri Mar 25, 2011 6:52 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Code: Select all

i++; // Increment i by 2
by Berengal
Thu Mar 24, 2011 9:42 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

What if I don't have any coding practices?
by Berengal
Tue Mar 15, 2011 11:48 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Not to forget Java: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; public class App { public static void main(String[] args) throws Exception { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByExtension("js"); eng...
by Berengal
Fri Mar 11, 2011 10:02 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Literally half the processing time is usually spent in that first step. If I get that working, I'll post my results. It's worse than half on average, but only by a constant factor. In the best case the time taken is halved on each step, making it O(n). In the worst case it's still O(n^2). On averag...
by Berengal
Sun Mar 06, 2011 12:55 am UTC
Forum: Coding
Topic: Java 4K Game Development Competition 2011!
Replies: 4
Views: 1269

Re: Java 4K Game Development Competition 2011!

It's less than 2^32768 since not everything is a valid jvm program., probably a few thousand orders of magnitude off. Still, 2^266; important computational constant: It's the number of atoms in the universe.

They're not running out of games anytime soon.
by Berengal
Tue Mar 01, 2011 3:05 pm UTC
Forum: Coding
Topic: Why is R different?
Replies: 25
Views: 7836

Re: Why is R different?

Many languages also use := instead of just plain =, just because they considered it bad form to steal an operator from another operation. Also noteworthy is Prolog, in which = does mean equality, with all the properties that entails, yet can still be used for assignment. This means that "X = 5&...
by Berengal
Tue Mar 01, 2011 5:51 am UTC
Forum: Coding
Topic: Why is R different?
Replies: 25
Views: 7836

Re: Why is R different?

If you ask anyone with even a slightly academic bent what they think about using = for assignment they're likely to start foaming at the mouth, or at least launch into a highly entertaining rant. The main point is that = is used for equality in mathematics. Now, equality can mean many different thin...
by Berengal
Tue Mar 01, 2011 5:13 am UTC
Forum: Coding
Topic: Extremely exceptional code; or abuse of exceptions in PHP
Replies: 12
Views: 2675

Re: Extremely exceptional code

Chained exeptions is pretty much the way to go almost everywhere you want to encapsulate an exception. I can only think of one exception (heh), and that's when you're serializing exceptions. There can be trouble if the serialized exception cannot be deserialized again (e.g. when you're sending it to...
by Berengal
Fri Feb 25, 2011 8:19 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

elminster wrote:It's annoying when trying to test something that requires network latency to test when you don't have remote server to put it on. I guess I could code/find some kind of proxy system that could simulate it.

A quick search gave me this: http://sourceforge.net/projects/wanem/
by Berengal
Fri Feb 25, 2011 1:09 am UTC
Forum: Coding
Topic: Learning Languages
Replies: 7
Views: 1567

Re: Learning Languages

After learning Java, what other languages should I take that are somewhat related to Java, and other languages related to those, and so on. You should learn languages that are as unrelated as possible. If you always stay in familiar territory, you'll never get out of the object-oriented procedural ...
by Berengal
Thu Feb 24, 2011 11:41 pm UTC
Forum: Coding
Topic: java, classes within classes
Replies: 4
Views: 1020

Re: java, classes within classes

The "correct" way of doing this the way you want would be to define Person something like // Note that it's customary to name classes in CapitalCamelCase public class Person { private int luck; private Country presidentOf; public Person(int luck, Country presidentOf) { this.luck = luck; th...
by Berengal
Mon Feb 14, 2011 9:51 pm UTC
Forum: Coding
Topic: [java] Search for implementing/extending classes
Replies: 2
Views: 471

Re: [java] Search for implementing/extending classes

Here you go. Have fun wading through java API documentation.
by Berengal
Mon Feb 14, 2011 12:56 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

For editing HTML, I'd recomend Zen coding. It's a bunch of plugins for various editor that has a very nice input mode for html.
by Berengal
Fri Feb 11, 2011 8:51 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Just thought I'd share what I'm working on with you. Properly anonymized by removing everything except code structure. public void foo() throws Exception { // ; ; ; ; ; ; ; ; ; ; ; while () { ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; if () { ; } ; ; ; // ; ; if () { if ( && ) { ; try { ; ; ; ;...
by Berengal
Sat Feb 05, 2011 2:12 pm UTC
Forum: Coding
Topic: List comprehension in haskell?
Replies: 3
Views: 1997

Re: List comprehension in haskell?

That function's not even typechecking correctly. f' clearly has type Int -> [[Int]], but it's applied to two Ints in the definition of funct.
by Berengal
Fri Feb 04, 2011 8:55 pm UTC
Forum: Coding
Topic: Ruby class-level method calls?
Replies: 2
Views: 856

Re: Ruby class-level method calls?

When Ruby stumbles upon attr_accessor it basically creates two methods for you. For example, if you where to write this: class Ruby attr_accessor :version end Ruby will automagically interpret it as: class Ruby def version @version end def version= value @version = value end end There's nothing mag...
by Berengal
Fri Feb 04, 2011 7:10 pm UTC
Forum: Coding
Topic: Java threadsafety
Replies: 5
Views: 963

Re: Java threadsafety

The only difference between synchronizing on the class and the map is that they are two different object. The class is only one instance, and so is the map (because it's static). You could have two regular objects, `Object foo = new Object(), bar = new Object();`, and the question would still be the...
by Berengal
Fri Feb 04, 2011 6:30 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Does anyone have any tips on writing absolutely bulletproof test cases? I'm a lowly intern, and my boss is having me automate some user interface testing with this thing called Selenium (http://seleniumhq.org/) in C# with nunit. I've done a little bit of testing in Java at school but I'd like to ma...
by Berengal
Mon Jan 24, 2011 7:35 am UTC
Forum: Coding
Topic: Layering java panels
Replies: 2
Views: 627

Re: Layering java panels

Because you use Java and was looking at JLayeredPanel, I assume you're using swing. In that case, is CardLayout what you're looking for? Make a panel, give it a CardLayout, then add all the components you need to the panel, probably with a blank one in front. Use the layout to choose which component...
by Berengal
Tue Jan 18, 2011 9:22 pm UTC
Forum: Coding
Topic: Memory leak in csv parser?
Replies: 5
Views: 1112

Re: Memory leak in csv parser?

A Char is a boxed 4 bit character. The box itself, if I remember correctly, is 16 bytes in the 64 bit runtime (8 for the pointer to the value, 8 for stuff I don't remember entirely, but the constructor is among them), which makes the character itself 20 bytes. The cons cell is a boxed pair of pointe...
by Berengal
Tue Jan 18, 2011 1:10 pm UTC
Forum: Computer Science
Topic: Pseudo machine code!
Replies: 10
Views: 2531

Re: Pseudo machine code!

For some reason I actually took the time to write an assembler for this embedded in Haskell. Not sure just how much of it to post since this is homework, but here's a program that reads in one line at a time, then prints it out. It stops when it gets a blank line. -- Jump if zero to absolute locatio...
by Berengal
Mon Jan 17, 2011 10:18 pm UTC
Forum: Computer Science
Topic: Pseudo machine code!
Replies: 10
Views: 2531

Re: Pseudo machine code!

Implicitly, the instruction register is loaded with the contents of the program counter, then the contents of it is executed based on the above table. Well, yes, I know that, but if there's no way of interacting with it, why do we need to care? Also, I wrote an emulator, and my brother and I wrote ...
by Berengal
Mon Jan 17, 2011 5:53 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Hi guys! This is what I have been thinking about lately, and I thought this would be the best place to ask this question. Does such a thing as a talented programmer exist? Or is it only a question of experience? If talent is an important factor in programming (which I think it is), could someone co...
by Berengal
Sun Jan 16, 2011 10:42 pm UTC
Forum: Computer Science
Topic: Pseudo machine code!
Replies: 10
Views: 2531

Re: Pseudo machine code!

What's the instruction register for? It doesn't look like you can read or write to it.
by Berengal
Sun Jan 16, 2011 9:29 pm UTC
Forum: Computer Science
Topic: What would you do if you could solve the Halting Problem?
Replies: 33
Views: 4528

Re: What would you do if you could solve the Halting Problem

I'd write a program that asked the oracle if the program itself would halt, and if yes, loop forever, if no, halt.
by Berengal
Sat Jan 15, 2011 4:51 pm UTC
Forum: Coding
Topic: Memory leak in csv parser?
Replies: 5
Views: 1112

Re: Memory leak in csv parser?

Regular strings in Haskell are singly-linked lists of boxed 4-byte characters. This is good, since it's easy to understand and all the standard list functions work on strings as well. It's bad if you're working with alot of strThis has two negative consequences: The first is that they're slow to wor...
by Berengal
Fri Jan 14, 2011 12:27 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

3 hours of really sharp flow and I've reimplemented my first-semester project from my uni days. The code is oh so much better now, spanning 250 lines (including tests), not 2500 (without any tests at all), and only one file instead of 20.
by Berengal
Mon Jan 10, 2011 8:07 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

Xeio wrote:
Robert'); DROP TABLE *; wrote:

Code: Select all

>>> True = False
>>> True == False
True
Wow, can you imagine figuring out what's going wrong if you had a typo like that (python allows assignments in conditionals, right?).

No it doesn't.
by Berengal
Sat Jan 08, 2011 5:24 pm UTC
Forum: Religious Wars
Topic: Is Java is a bad language for beginners?
Replies: 234
Views: 133101

Re: Is Java is a bad language for beginners?

this… is horrible! *shudder* i never thought it could be this bad. thanks for backing my point, i seldom get support when i make such statements. Sure, it looks horrible and my wrists hate me for it (even with major IDE support), but what you fail to realize is that not using closures is not an opt...
by Berengal
Fri Jan 07, 2011 4:13 pm UTC
Forum: Religious Wars
Topic: Is Java is a bad language for beginners?
Replies: 234
Views: 133101

Re: Is Java is a bad language for beginners?

public class App{ public static void main(String...args){ abstract class F{abstract void call(Object...args);} new Object(){void map(F f, Object...args){ for(Object arg : args){f.call(arg);}} }.map(new F(){public void call(Object...args){System.out.println(args[0]);}} , "They take my lambdas&q...
by Berengal
Fri Jan 07, 2011 5:00 am UTC
Forum: Coding
Topic: Oddly specific PHP exploit
Replies: 9
Views: 2654

Re: Oddly specific PHP exploit

How many are serving webpages from 32-bit intel CPUs anyway?
by Berengal
Tue Jan 04, 2011 6:16 am UTC
Forum: Coding
Topic: How do I speed up this code?
Replies: 16
Views: 1979

Re: How do I speed up this code?

If posting the code is an option, I'd be happy to take a closer look. I at least like puzzles like these. I'm leaving for work now, but I could take a look when I get back home.
by Berengal
Tue Jan 04, 2011 5:35 am UTC
Forum: Coding
Topic: How do I speed up this code?
Replies: 16
Views: 1979

Re: How do I speed up this code?

So, does removing the one call to fillRect speed it up considerably, or is it still slow?
by Berengal
Tue Jan 04, 2011 4:00 am UTC
Forum: Coding
Topic: Logging into a website and gathering data
Replies: 10
Views: 3899

Re: Logging into a website and gathering data

With javascript it becomes a bit harder. Chances are you'll still be able to log in pretty easily by just figuring out what the javascript does. After all, the server doesn't really have any way of verifying that you've run the javascript or not (and it certainly shouldn't care).
by Berengal
Mon Jan 03, 2011 5:57 pm UTC
Forum: Coding
Topic: How do I speed up this code?
Replies: 16
Views: 1979

Re: How do I speed up this code?

Did you try profiling it?

Because if you didn't then there's nothing to discuss until you do.
by Berengal
Mon Jan 03, 2011 5:39 pm UTC
Forum: Coding
Topic: Logging into a website and gathering data
Replies: 10
Views: 3899

Re: Logging into a website and gathering data

Get Apache's httpclient library, then look for something to parse html.

And yes, read the HTTP spec. Try logging into the site manually using something like telnet or netcat.
by Berengal
Thu Dec 30, 2010 10:36 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9990
Views: 2000558

Re: Coding: Fleeting Thoughts

I wonder how much 0-gen garbage you can churn for the cost of allocating, promoting and collecting a single 1-gen object. Particularly in the jvm, but also in other runtimes. Anybody know anything about this?
by Berengal
Wed Dec 29, 2010 5:42 am UTC
Forum: Coding
Topic: [FIXED]ClassNotFoundException on any Java program in Eclipse
Replies: 12
Views: 3904

Re: ClassNotFoundException on any Java program in Eclipse

You should check eclipse's global classpath, jre and jdk configurations. Also, eclipse puts the .class files it builds in project/bin (unless you changed it), so check to see that those exist and that eclipse actually builds the classes for you.

Go to advanced search