Be a Supporter!
Response to: Java StackOverflowErro r question Posted October 9th, 2011 in Programming

I think you've sort of got it down, but you shouldn't use stack overflow (as funny as that is) as a random number generator. Just so that you better understand stack overflow, it happens when you run out of memory. Java has two types of memory: (1) the stack & (2) the heap. Functions are placed on the stack (first in last out). The heap is where most of your variables go to get stored. You can run out of memory in either location, and you can change the size of memory allocated to java to help avoid this issue. Because of that you can never *guarantee a stack overflow will happen. But if you're using an infinitely recurssing function there's a pretty good (certain) chance it will happen on todays computers with todays compilers.

As you've figured out, a when a method calls itself it takes up a bit of memory. Eventually this program fills that up. When that happens is machine dependent. Technically, if you ran this program on the same java machine with the same starting state, over and over, you'd get the same result. Its only random because the java virtual machine (you'll learn about that later) optimizes code on the fly rather than using machine code. This gives you the sense that something random is happening when it isn't.

Certainly a neat homework problem. I'd say you found the bug, hopefully you've learned something. :)

Response to: Java StackOverflowErro r question Posted October 9th, 2011 in Programming

At 10/9/11 06:36 AM, Sandremss128 wrote: for (intParNR2 = localInt2;; localInt3++)
{
localInt3++;
break;
}

A for loop consists of 3 parts (normally). Variable definition ; Condition (if the condition evaluates to true, you go through the code again, otherwise exit) ; some code to run after a loop has completed, but before the condition is evaluated.

Basically, NR2 gets set to localInt2. There is no condition, so I'm not sure if the code even runs (you could check with a debugger or System.out.println() ). If it did run, it would increment localInt3 by 1, and then break would exit the for loop.

All the variables are defined integers. My questions is what happens if you have a for loop and the part where you normally put the condition is empty?

Why don't you try it out? That should take 2 seconds to check.

My compiler warned here for 'dead code' (2 times).

Warnings tell you that there is an issue, but not one that breaks the program. What the compiler is suggesting is that the for loop does nothing, which is probably true.

Even if the loop executes it only increments the local integer nr 3 by 1. My question is:
Will intParNR2 be assigned to localInt2?

Is there any code that does that? Because I don't see it.

Will localInt3 be incremented by the loop part?

Unlikely, but test to make sure. That's the point of homework.

Will localInt3 be incremented in the body of the loop?

That depends on whether the code executes. Test and find out.

Response to: PHP: Write/update webpage to server Posted October 5th, 2011 in Programming

At 10/5/11 11:59 AM, SupJD wrote:
At 10/4/11 07:59 PM, gumOnShoe wrote: md5 & SHA-2 aren't strictly speaking encription. They are 1 way hashing algorithms. There is no way to get back the actual password which is really the point.
Yeah, sorry I used the wrong terminology :P

I was under the impression you could use brute force to reverse the process of hashing though? An automated system which can crack it in a pretty reasonable time scale. The same is still possible with SHA but it just takes more time and more processing power. I'm not entirely 100% sure on all this though, it's just from little bits I've read now and then.

Technically you can't use bruteforce to undo a hash. A hash algorithm is like the remainder in devision. You can always get the remainders that look similar from different options. That said, there's a discrete set of possible inputs to give you a resulting hash. So, it is possible to bruteforce a password scheme, and it is possible to build a dictionary of hash values based on real words (which is why people talk about salts), but it isn't possible to reverse the math of the hash algorithm itself. The bruteforce literally is the same as a bruteforce attack on "what word am I thinking of?" with a few more algorithmic steps.

Response to: Occupy wall street media black out Posted October 5th, 2011 in Politics

At 10/3/11 01:03 AM, SadisticMonkey wrote: Wow I really didn't realise just HOW stupid these gys are.

Strawmen. Easy.

Response to: Would you have gay sex to be a mod? Posted October 5th, 2011 in General

At 10/5/11 04:03 AM, Coop wrote:
At 10/5/11 03:48 AM, Gagsy wrote:
At 9/24/11 07:06 AM, Coop wrote:
Maybe it's just me reading too much into it, but I'd like to know if you're talking girl-girl, with scissoring etc, or whether you're talking if you were a guy, you'd like to fully explore the "joy" of cock, balls and prostate?
The only way to tell you Coop would be to show you.
Yes, but I can't take part in scissoring - my balls would get in the way :3

The funny thing? Scissors would entirely solve this.

Cringe! Cringe! Crinngggeeee!

Response to: I am about to go to court. Posted October 5th, 2011 in General

Odds are your were driving drunk if its a bike issue, that or you broke some sort of moving law. Regardless, assuming you aren't pleading guilty, you need to be as polite as possible, clean up, and not act like an idiot. That is, don't look like a liar. If you get trapped because of the evidence and you keep denying it you risk making yourself look back. Trial is 90% judging the character of the witnesses and accused. But the other 10% can have a huge impact on how people view you.

Don't be an idiot. Be polite. Dress well. Best advice I could give you. But clearly you already broke rule #1 or you wouldn't be in this situation.

Response to: PHP: Write/update webpage to server Posted October 5th, 2011 in Programming

Actually the store was a better example than I realized. Newgrounds doesn't generally use https:\\ but they do for their store. There you go a perfect example of when to use it. Don't worry about it so much with passwords. Worry about it with credit card numbers and contact info.

Response to: PHP: Write/update webpage to server Posted October 5th, 2011 in Programming

At 10/5/11 01:19 AM, NinoGrounds wrote: You might have errors here. You mean, the attacker can see the password when the user signs up before it reaches to the server. So he sees a real, raw, unecrypted password. Right? Because I don't think it's possible for attacker to see it when it reaches the server, and when it gets encrypted.
I am creating a random salt server side every time a user signs up.

I also have a question, since I've never been using HTTPS, but I am strongly considering it now. If I decide to use HTTPS, should I also force using SSL when exchanging data with database?

In an ideal world yes. However, SSL means decripting data, which means there's additional processing time that needs to happen on your server and on their computer. This will on some level slow down your site and hit performance (unless you have a very robust server).

However, it would depend on what you are actually doing. You'll notice that Newgrounds doesn't use https for its password system. I'm not even sure that they do it for their store. The question you have to ask yourself is: Are users doing something on my site that absolutely needs protection. If users are using social security numbers, or other identity information on your site regularly, I'd agree you probably need to do something more than what you are. I'm not sure https is required for a simple user system.

In the end, how much of your time and money is it worth to fight an eventual losing battle? Man in the middle and all of that is a scary attack you can sort of protect against, but if your customers download a key logger it doesn't matter what you do.

Response to: PHP: Write/update webpage to server Posted October 4th, 2011 in Programming

At 10/4/11 08:04 PM, NinoGrounds wrote:
At 10/4/11 07:59 PM, gumOnShoe wrote: wizdom
So by you, using https to protect data while in carriage and using crypt() with salt isn't enough? Or were you referring to the public/private keys of HTTPS ?

public/private keys is the way https works. Basically, you need to have a secure connection using very long secret passwords to guarantee anything. Salt is fine. I wouldn't swear by it. It definately keeps users from using a dictionary attack against your hash algorthm; unless they can find out the salt, but you are hopefully salting server side anyways, otherwise everyone can see the salt, But to salt server side, you have to pass the password over the net, and to do that safely, unencrypted, you need to have a secure https connection.

Response to: PHP: Write/update webpage to server Posted October 4th, 2011 in Programming

At 10/2/11 11:01 PM, SupJD wrote:
At 10/2/11 10:42 PM, NinoGrounds wrote:
At 10/2/11 03:19 PM, SupJD wrote: username, email, password (make sure its encrypted)
You guys encrypt usernames and emails too? I mean it makes sense for emails, but for usernames too? I never really encrypted usernames and emails. You're using md5 right ?
I don't encrypt usernames and I don't usually encrypt emails either, depends on the project... I put brackets round that just meaning for passwords more than anything.

And I personally advise no longer using the md5 hash, you want to use SHA-2.

md5 & SHA-2 aren't strictly speaking encription. They are 1 way hashing algorithms. There is no way to get back the actual password which is really the point. That said, if a user suffers from a man in the middle attack, it doesn't much matter which hashing algorithm you use. The offending party can simply send the hash on instead of the password. Without an actual encryption (private key/public key system) you can't build a completely safe to use system where you are literally covering everything you can as a web designer.

Response to: PHP: Write/update webpage to server Posted October 2nd, 2011 in Programming

Thanks for all the tips anyone, and I see you remember what I'm using Sam. I've got to say, its not always the best service though. Their method for stopping you from going over your ram limit is to kill a process. But I'm not sure that they are killing things intelligently, which sometimes leads to site outages. But yes, I know what RAM is. I'm guessing that comment was deleted.

At 10/2/11 08:59 PM, kaiser-d wrote: If you expect a small user base, you can write user account details as xml nodes. If you expect a larger user base, create an SQL database and use php to write user data to that. Do not use XML to store user passwords or sensitive information.

I'm staying away from XML. I have a personal hatred for the stuff. Yeah, I know HTML is a subset, but its a pet peeve of mine regardless. And I've already got a database that I'm storing stuff in, including users. I just hadn't done anything with the information being saved yet and was wondering on the best way forward. Everyone seems pretty much in agreement that PHP is better than individual pages based on a template? That's probably the easiest way to do it anyway...

Anyway, brownies just finished baking. MMM brownies.

Response to: Safecount.net ad Posted October 2nd, 2011 in General

http://www.techspot.com/vb/topic85000.ht ml

08-21-2007

Julio
TechSpot Executive Editor

Location: Ecuador
Member since: Feb 2002, 5,227 posts
System specs
I tracked down the pop to IntelliTXT. Already sent a serious complaint.

Hope that helps or something...

Response to: PHP: Write/update webpage to server Posted October 2nd, 2011 in Programming

At 10/2/11 01:35 PM, NinoGrounds wrote: Avoid this style. Soon you'll have a ton of files and folders. Hard to maintain. Store users' data in a single file or db. I prefer databases, for a ton of reasons. And then you simply create a template.php file, where the template code is, and then you just fetch users' data into it. Thus, you are creating pages "on the fly".

Mmmk, I'll look into doing it this way instead. I'm a little worried about every user ever needing to compile a complete PHP page when they load their user page or someone else does, but I see what you are getting at. Hard disk space for me is infinite, but I pay for ram.

PHP: Write/update webpage to server Posted October 2nd, 2011 in Programming

Hey, just wondering who has experience with doing this sort of thing and what method you would use to do it. As a basic example, a user (lets call him FooMaster) signs up to your web page. You have a directory called "users" on your webserver, and in there you want to create a folder called FooMaster with index.php located at that link. And then you have a template and you'll just update it based on the information FooMaster gives you.

I'm assuming this is possible. How else would you make web pages on the fly?

Thanks much for the direction.

Response to: Website Graphical Mask Posted September 26th, 2011 in Programming

At 9/26/11 04:01 PM, thePalindrome wrote: You could put one image with transparency on top of another with a difference in z-levels, but I think IE has issues with image transparencies...

I figured it out. There's a way to use the new canvas object with javascript to accomplish what I want. It works in chrome & firefox. I don't have opera to test, and I'm upgrading IE (which I never use), if I can, in order to test in that. But frankly, if it doesn't work in IE, I'm not sure how much I care.

http://gumonshoe.net/NewCard/MaskTest.ht ml

Basically, you use a PNG with alpha and set another images alpha values using java script equal to the mask's alpha values.

You can view the JS here:
http://gumonshoe.net/js/canvasMask.js

Website Graphical Mask Posted September 25th, 2011 in Programming

Anyone who has worked in flash or photoshop should know that a mask is essentially a graphical piece that hides part of an image while showing the rest. You can find plenty of tutorials that explain it on the web. Basically, you have an image. You create a new layer above it. Wherever the new layer (mask layer) is black, the layer below it shows. Whereever the mask is white, everything else dissapears. This is very useful when working with graphics, and web design is all about graphics, so I was hoping there was a way to do this across many browsers.

The only ones that seem to do this are webkit browsers. Or am I wrong. Anyone have any ideas?

Thanks.

Response to: innerHTML expected behavior? Posted September 19th, 2011 in Programming

At 9/19/11 03:38 AM, BUCHANKO wrote: Just for the record...

You cannot self enclose <div> tags, they should be properly closed with a </div>

Yeah i figured that out last night... a bit weird, but ok.

Thanks. That fixed the issue.

innerHTML expected behavior? Posted September 18th, 2011 in Programming

Hey, doing some web programming.

I'm using innerHTML to change the look of my page. I suppose I ought to learn the insert & remove dom element functions, but I was just going with what I knew and I started recognizing unusual behavior. Wasn't sure if it was Chrome or if it was expected.

If I have the following:

<div id="container">
    <div id="blah1"/>
    <div id="blah2"/>
    <div id="blah3"/>
</div>

Then, when I do:

document.getElementById('blah2').innerHTML="Some Random Text";

Rather than just changing that element, I find that it wipes out everything in the element AND everything after it. The above would give me:

<div id="container">
    <div id="blah1"/>
    <div id="blah2">Some Random Text</div>
</div>

Notice that blah3 dissapeared. Again, I was just wondering if this was expected. It seems like a bug to me, but I've seen it a few times and I'm new to this so maybe I'm just crazy and expect too much.

Response to: post/get javascript -> php Posted September 11th, 2011 in Programming

At 9/11/11 06:45 PM, citricsquid wrote: [ not (

$_GET['username'];

enable PHP errors (have it set to report all during local development) as it would have caught this.

I typed it up wrong here. It turned out to be something completely different. I must have had a type somewhere after re-writing it over and over again I must have just done it right. I move back to using ?, found it the vars in the $_GET[] array and went from there.

Thanks for the help, though.

Web programming is soooo messy. Ugh.

post/get javascript -> php Posted September 11th, 2011 in Programming

I'm attempting to pass variables to a PHP file using javascript. Its a basic log in function. I know I'm not getting a 404 because my error reporting comes back, but when, in PHP I check for

$_GET("username")

, nothing comes up. I checked post too just to be sure. Clearly I'm doing something wrong here. Thoughts?

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "myAccepter.php", true);
xmlhttp.send("username=" + uName + "&pass=" + pWord);
Response to: Millenials: The Lost Generation Posted September 10th, 2011 in Politics

If you look at research, people like us who graduate during a recession make significantly less for the rest of their lives than other people of a similar age.

We just got fucked up the ass because our parents are idiots.

Random number generator fail. :(

Response to: How to fix the economy Posted September 9th, 2011 in Politics

Start new industries here and support them (IE transportation over hauls), with government aid if need be. Stop worrying about the deficit. As a percentage of GDP its amoung the lowest rates in the developed world. Stop cutting state budgets. The thing offsetting employment gains has been public sector layoffs.

A successful transportation overhaul will mean many construction jobs now, and manufacturing jobs later since it will decrease shipping costs and lower our bottom line. If the government drives damand, at least there will be demand.

The point is someone needs to spend money. If the U.S. government has to prime the pump until big business takes over, that's fine.

While I don't believe a Republican president would be good for this country, I am starting to feel a less polarizing individual is needed. I like Obama. I want him to be our president. But apparently my neighbors are too childish and biggotted to handle it. D minuses for all.

Response to: "trickle down" economics= Socialism Posted September 8th, 2011 in Politics

At 9/8/11 05:13 AM, SadisticMonkey wrote: Monopolised industries would have huge profits. Huge profits attract investors. Hence, monopolies destroy themselves.

I don't follow.

A monopolised industry does attract investors. But its the large company that attracts them because the gain should be higher from the large company over a start up. Plus the point of the monopoly is that most of the money for that industry is already going to one place. If you want to make money, you'll invest in the monopoly and you'll sell to the monopoly. And if you try to do something else, the Monopoly will have the buying power to ignore you, cut you out of deals, and in general make your life hell by undercutting your prices until you can't afford to stay in business. (And since you don't like regulation, there's nothing you'd be able to do to stop this. As there's real evidence of this happening, I don't follow your claim. This is why Microsoft was sued for anti-trust).

So under your economic world view:

1. There are only a limited number of jobs ever possible, so some have to be kept unemployed so that others can remian employed.
2. Americans are entitled to said employment more than people from any other nation

We're becoming more isolationist over here, that's true. And its a result of a bad economy. But the prevalent view over here is that we should take care of our own first. I wouldn't be surprised to see tariffs as an option if this continued for 4 more years. And I know how bad that would be for the global economy, but oh well. China already does and so do plenty of other nations. Its hard to play fair with people who don't want to play fair.

there through competitive marketing styles and
You honestly believe that people shop at walmart because of their marketing?

Eh, if you consider low prices part of marketing...

predatory business.
Hahah. So walmart is literally spending decades having low prices (i.e. reducing the cost of living) so that one day when everyone else is wiped out, they'll jack up prices.

Walmart has also for decades paid their employees less than their competitors which has reduced their employees standard of living. Its a double edged sword.

Beyond that quality has gone way down on our goods because price has taken position over quality. So our goods are not as durable and do not last as long. In general that means we end up wasting more money on shit goods more often. Which is actually even worse for our pocket books.

Walmart is like Crack Cocaine or McDonalds. Its bad for us, but people keep doing it anyways.

Yeah okay cool, literally no one here is in support of unemployment. However, as the past 3 years have shown, the government is utterly incapable of creating jobs.

That's not really true. The government actually did save plenty of jobs by reinforcing state budgets. The proof is that now that the stimulus money is drying up you see all of these teachers and construction workers losing their jobs.

We've also created a new energy market in our country.

But we've done it in a way that still allows bad ideas to fail.

We're in bad straits. We barely avoided a depression. Now we're in a stagnated economy with nothing causing us to go up at the levels we were used to with a bubble economy.

So, its not a good place to be...

Response to: Obama 12: Invincible or Unelectable Posted September 5th, 2011 in Politics

At 9/4/11 11:50 PM, MillsApparatus wrote: Obama should never have been president in the first place. It's the White House for a reason.

I.

We hold these truths to be self-evident,that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the Pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed.

II.

Section 1. All persons born or naturalized in the United States, and subject to the jurisdiction thereof, are citizens of the United States and of the State wherein they reside. No State shall make or enforce any law which shall abridge the privileges or immunities of citizens of the United States; nor shall any State deprive any person of life, liberty, or property, without due process of law; nor deny to any person within its jurisdiction the equal protection of the laws.

Section 2. Representatives shall be apportioned among the several States according to their respective numbers, counting the whole number of persons in each State, excluding Indians not taxed. But when the right to vote at any election for the choice of electors for President and Vice President of the United States, Representatives in Congress, the Executive and Judicial officers of a State, or the members of the Legislature thereof, is denied to any of the male inhabitants of such State, being twenty-one years of age, and citizens of the United States, or in any way abridged, except for participation in rebellion, or other crime, the basis of representation therein shall be reduced in the proportion which the number of such male citizens shall bear to the whole number of male citizens twenty-one years of age in such State.

III.

Civil Rights Act of 1964:

Title III
Prohibited state and municipal governments from denying access to public facilities on grounds of race, color, religion or national origin.

itle VII of the Act, codified as Subchapter VI of Chapter 21 of 42 U.S.C. § 2000e [2] et seq., prohibits discrimination by covered employers on the basis of race, color, religion, sex or national origin (see 42 U.S.C. § 2000e-2[31]). Title VII also prohibits discrimination against an individual because of his or her association with another individual of a particular race, color, religion, sex, or national origin. An employer cannot discriminate against a person because of his interracial association with another, such as by an interracial marriage.

In other words. Shut your stupid fucking mouth, you stupid fucking racist.

Response to: Warren Buffett's debt solution Posted August 31st, 2011 in Politics

At 8/31/11 02:05 AM, SadisticMonkey wrote:
At 8/30/11 09:29 PM, gumOnShoe wrote: More to the point, is it conceivable that there might be a time when raising the debt is good, important or necessary?
apart from defensive war, no.

Imagine trying to fight WII without debt spending. Yeah good luck.
The obvious solution would be to allow for debt if (and only if) congress declares war.

Unfortunately, other people than you & I declare war. And all we need is another Bush to declare a War on some inane idea he can't hope to fight and we're back to deficit spending. Hell, at that point you might just be telling congress that it should be continually at war. Because if it isn't, there's a good chance they're all going to get fired.

Response to: I think I'm in love. Posted August 31st, 2011 in General

Me From 10 years ago:

Holy shit, we should call help. That woman needs to go to rehab/hospital/asylum asap. Lets contact you tube and get the authorities on this one.

Me Now:

Genius! Think of all the drugs she can buy to further fuel her drug addled rantings with all of the you tube money she's making off those hits.

....

Yeah, I more cynical now. Also, pretty glad I don't do drugs.

Response to: Warren Buffett's debt solution Posted August 30th, 2011 in Politics

If congress is a rotating door than the eventually it just becomes a stepping stone to another job. Mandatory turn over generally doesn't lead to better legislation wherever its been put in place.

More to the point, is it conceivable that there might be a time when raising the debt is good, important or necessary?

Imagine trying to fight WII without debt spending. Yeah good luck.

Warren Buffet might be good at making a fortune, that doesn't mean he's good at governing. It means he's good at being a parasite.

Response to: Boo! Posted August 25th, 2011 in General

At 8/24/11 01:38 PM, The-Great-One wrote: What the fuck did my brain just get fucked?

However why can't you have both? Work at Microsoft, be married, and with a car?

I'm on the east coast. Microsoft is on the west coast. If I move and my fiancee stays for the year because she wants to finish out teaching the year, then one of us needs the car and the other has to figure out other transportation. We also can't get out of our lease ($800 a month). I'll be planning a wedding from across the country too, because we've already booked a place where we live now. That's pretty much why. In a year it'd all work out, but in the mean time. ;(

Response to: Anyone ever read Nietzsche? Posted August 24th, 2011 in General

Eh just keep in mind that *nothing matters* is supposed to be a positive line, not one meant to throw you into complete depression. If you get bogged down or saddened, you're probably missing the point. I have no recomendations on what you should read. Just a friendly warning that he's often misread.

Boo! Posted August 24th, 2011 in General

Hey some guy you din't realize got demodded (and he was a great one (i'll toot my horn if i feel like it (nested parens </coding joke))) and is posting years later, or some guy you've never met suddenly has more posts than you, used to be more famous than you on the internet, and used to mod here (which is probably your teenage nerd wet dream). Irregardless, surprise I (still) exist. I know, I know. That was lame.

What is this really about? The mental fallout of posting too much on the internet lasts for decades. No literally, my post per day average won't drop down below one until after I'm 60 years old. Like, wowie, right? I just said wowie deal with it.

Long after you leave here, you'll have an itch to fill that vacuum in your life to have that sudden recognition and feedback you once had on the internet. Even after you're successful, have money and what not, you'll still wonder what those people on the internet would say if you told them you had a promotion, or got the last cookie off the office cookie platter. Mostly, you avoid it though. But not today.

So, here's a quicky advice question. I have an opportunity to apply for a job at Microsoft, and possibly get one. Yay! I'm stuck in a year long lease. I'm getting married next summer. And we only have one car. What should I do?

Apply for the job at Microsoft, I know. But, hey I really wanted to post something. Hi! Bye!