Open Side Menu Go to the Top

08-01-2012 , 06:59 PM
shopping cart
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
08-01-2012 , 09:55 PM
Quote:
Originally Posted by gaming_mouse
kyle, what part of stripe is not fully functioning?
Quote:
Originally Posted by kyleb
shopping cart
laughed out loud for real
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 12:55 AM
have we talked about theprofoundprogrammer yet? (note: contains adult language)

Spoiler:




** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 04:29 PM
LOOOOOOL

Spoiler:
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 05:51 PM
haha. That reminds me of the Python repl:

Code:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-Z plus Return to exit
>>>
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 07:31 PM
So I've just started learning coding this summer (just finished Udacity 101). I'm trying to work with javascript for the first time to make a calculator for my blog, and I've run into a problem. Excuse my extreme noobness...

I got the a basic "add two numbers" calc example from a tutorial. I've tried to convert it into my own calculator for this energy reading device I like to use. The code below works, but I'd like to take it further by having it print out the value per day/month/year/50 years.

This is done pretty simply by taking the per hour rate, * 24, then *30, and so on. I made a little program in Python to do this by just assigning new variables and printing them all out. However, to get javascript to do this on a webpage isn't quite the same?

Would I: assign variables to per hour/ per day/ per month/ per year, and have those print out on the web page?

Or: assign multiple form.Answer.value? Is this possible, can I make things like form.Answer1.value (I tried this to no avail but I am a bit blind here).

Or do I have to make multiple functions, one for each value I want to print out, and then have these functions nested into one big function that is run onclick?

Thanks for any help..

HTML Code:
<HTML>
<HEAD>
<TITLE>Kill-a-watt Calculator</TITLE>

<!-- saved from url=(0030)http://www.sciencebuddies.org/ -->
<!-- When this code is saved as a local file, the preceding line tells Internet Explorer to treat this file according to the security rules for the Internet zone (plus any security rules specific for the Science Buddies website). -->
<SCRIPT LANGUAGE="JavaScript">
<!-- old browsers can't handle JavaScript functions so comment them out

function Calculate_cost_per_hour(Atext, Btext, Ctext, form)
{
var kW_used = parseFloat(Atext);
var hours_run = parseFloat(Btext);
var local_rate = parseFloat(Ctext);
form.Answer.value = ((kW_used / hours_run) * local_rate);
}

/* ClearForm: this function has 1 argument: form.
   It clears the input and answer fields on the form. 
   It needs to know the names of the INPUT elements in order
   to do this. */

function ClearForm(form)
{
form.input_kW_used.value = "";
form.input_hours_run.value = "";
form.input_local_rate.value = "";
form.Answer.value = "";
}

// end of JavaScript functions -->
</SCRIPT>
</HEAD>

<BODY>

<P><FONT SIZE="+2">Kill-a-Watt Calculator</FONT></P>

<FORM NAME="Calculator" METHOD="post">
<P>Enter the kilowatts (kW) used: <INPUT TYPE=TEXT NAME="input_kw_used" SIZE=10></P>
<P>Enter the hours run: <INPUT TYPE=TEXT NAME="input_hours_run" SIZE=10></P>
<P>Enter the local kilowatt-hour (kWh) rate: <INPUT TYPE=TEXT NAME="input_local_rate" SIZE=10></P>
<P><INPUT TYPE="button" VALUE="Calculate Device's Cost" name="kWhButton" onClick="Calculate_cost_per_hour(this.form.input_kw_used.value, this.form.input_hours_run.value, this.form.input_local_rate.value, this.form)"></P>
<P><INPUT TYPE="button" VALUE="Clear Fields" name="ClearButton" onClick="ClearForm(this.form)"></P>
<P>Cost Per Hour = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
<!-- <P>Cost Per Day = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
<P>Cost Per Month = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
<P>Cost Per Year = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P>
<P>Cost Per 50 Years = <INPUT TYPE=TEXT NAME="Answer" SIZE=12></P> -->
</FORM>

</BODY>
</HTML>
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 08:56 PM
I quickly threw together a version that does what I think you were trying to do. I added comments to give a little bit of explanation. Also, I added ID attributes to each of the input fields so it would work with my JS code.

Let me know if you have any questions.

Code:
<HTML>
<HEAD>
<TITLE>Kill-a-watt Calculator</TITLE>

<!-- saved from url=(0030)http://www.sciencebuddies.org/ -->
<!-- When this code is saved as a local file, the preceding line tells Internet Explorer to treat this file according to the security rules for the Internet zone (plus any security rules specific for the Science Buddies website). -->
<SCRIPT LANGUAGE="JavaScript">
<!-- old browsers can't handle JavaScript functions so comment them out

function Calculate_cost_per_hour()
{

/*
    Instead of passing arguments to this function like you were,
    I instead opted to get the value of the element with getElementById
    and then calculate each metric.
    
    Note that I combined all of the variable declarations into one
    var statement. It makes your code much more readable and is considered
    to be a better practice to follow.
*/

var kw_used = document.getElementById('input_kw_used').value,
	hours_run = document.getElementById('input_hours_run').value,
	local_rate = document.getElementById('input_local_rate').value,
	hourly  = ((kw_used / hours_run) * local_rate),
	per_day = hourly * 24,
	per_month = per_day * 30,
	per_year = per_day * 365,
	per_50_years = per_year * 50;
	
/*
    After getting the value of each input and calculating
    the metrics, we use the same getElementById method to
    set the value of the element.
*/
	
	document.getElementById('per_hr').value = hourly;
	document.getElementById('per_day').value = per_day;
	document.getElementById('per_month').value = per_month;
	document.getElementById('per_year').value = per_year;
	document.getElementById('per_50_years').value = per_50_years;
}

function ClearForm()
{
/*
    Same as above except we're setting the element value
    to an empty string.
*/
	document.getElementById('input_kw_used').value = '';
	document.getElementById('input_hours_run').value = '';
	document.getElementById('input_local_rate').value = '';

/*
    Here I used the getElementsByName method. Since more than
    one element can have the same name, this method will
    return an array.
    
    We find out how many elements have the name 'Answer'
    by finding the length of the array, and then all
    we have to do is use a for loop to iterate over 
    each element in the array, setting each value to an empty string.
*/
	var answers = document.getElementsByName('Answer'),
		num_answers = answers.length;

	for (i=0; i<num_answers; i++) {
		answers[i].value = '';
	}
}

// end of JavaScript functions -->
</SCRIPT>
</HEAD>

<BODY>

<P><FONT SIZE="+2">Kill-a-Watt Calculator</FONT></P>

<FORM NAME="Calculator" METHOD="post" id="calcform">
<P>Enter the kilowatts (kW) used: <INPUT TYPE=TEXT NAME="input_kw_used" ID="input_kw_used" SIZE=10></P>
<P>Enter the hours run: <INPUT TYPE=TEXT NAME="input_hours_run" ID="input_hours_run" SIZE=10></P>
<P>Enter the local kilowatt-hour (kWh) rate: <INPUT TYPE=TEXT NAME="input_local_rate" ID="input_local_rate" SIZE=10></P>
<P><INPUT TYPE="button" VALUE="Calculate Device's Cost" name="kWhButton" onClick="Calculate_cost_per_hour()"></P>
<P><INPUT TYPE="button" VALUE="Clear Fields" name="ClearButton" onClick="ClearForm()"></P>
<P>Cost Per Hour = <INPUT TYPE=TEXT NAME="Answer" id="per_hr" SIZE=12></P>
<P>Cost Per Day = <INPUT TYPE=TEXT NAME="Answer" id="per_day" SIZE=12></P>
<P>Cost Per Month = <INPUT TYPE=TEXT NAME="Answer" id="per_month" SIZE=12></P>
<P>Cost Per Year = <INPUT TYPE=TEXT NAME="Answer" id="per_year" SIZE=12></P>
<P>Cost Per 50 Years = <INPUT TYPE=TEXT NAME="Answer" id="per_50_years" SIZE=12></P>
</FORM>

</BODY>
</HTML>
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 10:11 PM
A start-up says that 80% of its ad-clicks from facebook were from bots.

http://techcrunch.com/2012/07/30/sta...ing-from-bots/

http://news.ycombinator.com/item?id=4312731

And then facebook releases a report saying that 83 million of its users are fake.

http://www.nydailynews.com/news/nati...icle-1.1127486

This will probably be a disaster for it's advertising revenues. The crusty marketers are looking for any good excuse to pull ad dollars from things they aren't sure are dogs. This rumor alone will cause them to pull dollars quickly, but if the data is out there to back up the claim, that's it, completely. Apparently, fb has awful customer service.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 10:27 PM
ya, I picked the wrong darling tech IPO to start investing on...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 10:28 PM
Yeah I read that 80% bot clicks article on HN the other day. No huge surprise.

What really did surprise me though, people are paying CPC on Facebook?!?!? even worse there's no mention of paying CPM, which afai recall was the very standard recommendation for running fbads years ago. CPM, low budget caps, very (VERY) tightly filtered targeting, accurate tracking, cull under converting adgroups fast.

also this lol: http://www.bbc.com/news/technology-18819338
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 10:58 PM
sdturner,

That's awesome! Thanks so much. I just played around with it and it was what I was looking for. I'll have to analyze the code tomorrow and see if I understand it all.

Again, thanks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-02-2012 , 11:57 PM
Quote:
Originally Posted by FourFins
sdturner,

That's awesome! Thanks so much. I just played around with it and it was what I was looking for. I'll have to analyze the code tomorrow and see if I understand it all.

Again, thanks.
You're welcome. Feel free to post problems or PM me anytime you get stuck with something. I'm always glad to help out someone trying to learn on their own.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 08:33 AM
Like I said wouldn't run any FB adds. Couple of friends of mine had pretty strong bot/puppet account suspicions.

It's good for branding, having a company FB site and doing stuff like "like us to enter a raffle" and as a decent customer support channel.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 08:45 AM
We spent over £1,000 on a FB campaign on FB to acquire new likes. It seemed to work very well and we got lots of new likes from the demographic we targeted but I basically since haven't seen any interaction from those new likes or increased activity even though the new likes represent around 30% of our total likes. Now that the news is saying about all these bots it's going to be highly unlikely we will ever run a FB campaign again as there is too much uncertainty and I've lost even more confidence in FB. FB haven't even addressed it all as far as I can see, without trust with an advertising platform you have nothing.

If we got duped in any way either by FB directly (unlikely) or FB's intentional lax rules around bots clicking on adverts (more likely) it makes me feel quite pissed off!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 10:03 AM
And to make matters worse it's actually worse to have fake likes than no likes. If all likes are legit you at least know everyone that liked you is actually interested in what you have to offer.

Could have used the 1k to sponsor best game of the month=100 pounds for almost a year and I'm pretty sure that would have generated some decent buzz. Combine with blog posts reviewing the games etc. pp
[assuming it was you that developed the game builder thingy...i get people mixed up all the time]

Or could have given away money to the highscore champs for some games build with your engine and so forth

If you use any of those ideas...write me a glowing recommendation page I can use for my CV imo (marketing consultant)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 12:06 PM
Quote:
Originally Posted by _dave_
Yeah I read that 80% bot clicks article on HN the other day. No huge surprise.

What really did surprise me though, people are paying CPC on Facebook?!?!? even worse there's no mention of paying CPM, which afai recall was the very standard recommendation for running fbads years ago. CPM, low budget caps, very (VERY) tightly filtered targeting, accurate tracking, cull under converting adgroups fast.

also this lol: http://www.bbc.com/news/technology-18819338
Since FB ads are sold by auction (or at least were when I used them), at least in theory the price of CPC and CPM should reflect what you said.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 12:26 PM
Also, I'm sure the bot problem on Facebook is serious, but that 83M number is incredibly misleading because the vast majority of them are people's second account or people's joke account. Those are run by people, so they're not really the kind of "fake" users that really screw over advertisers.

Quote:
The largest group of phony users, 4.8 percent, is comprised of duplicated profiles, defined by Facebook as "an account that a user maintains in addition to his or her principal account."

About 2.4 percent are user-misclassified accounts like a personal profile for a pet and 1.5 percent are "undesirable" accounts used for spamming.
Of course, facebook is still saying that 15M of its users are for spam, which is obviously huge, and presumably the actual number is significantly higher.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 12:31 PM
Compare that to twitter tho.... 15M is probably the number of spam accounts created per day
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 12:56 PM
My dog's account is not used for spam.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 01:02 PM
Quote:
Originally Posted by clowntable
Could have used the 1k to sponsor best game of the month=100 pounds for almost a year and I'm pretty sure that would have generated some decent buzz. Combine with blog posts reviewing the games etc. pp
[assuming it was you that developed the game builder thingy...i get people mixed up all the time]
Those are good suggestions, and we do some similar stuff. We're OK dropping a bit of money running experiments on various platforms/techniques though so it's not too much of a problem.

This is another reason why I absolutely detest web spam in all forms. Fake Twitter followers, fake Facebook accounts, etc etc just screw lots of stuff up for everyone.

Last edited by Gullanian; 08-03-2012 at 01:07 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-03-2012 , 06:35 PM
Anyone good with Java Binary Search Trees?

I'm converting an int BST to a generic for a HW assignment. Can anyone see anything wrong with my contains() or add() code? No new methods I make seem to work correctly, so I am thinking they problem may stem from add or contains. Specifically, I think I may be using the compareTo() method incorrectly?

private IntTreeNode<T> overallRoot;

Code:
// Returns true if the overall tree contains the given target value,
// false otherwise
public boolean contains(T target)
{
	return contains(overallRoot, target);
}

// Returns true if a portion of the overall tree contains the given
// target value, false otherwise.
private boolean contains(IntTreeNode<T> root, T target)
{
	if (root == null)
	{
		return false;
	}
	else if (target.compareTo(root.data) < 0)
	{
		return contains(root.left, target);
	}
	else if (target.compareTo(root.data) > 0)
	{
		return contains(root.right, target);
	}
	else
		return true;
}
	
// Adds the value to the tree such that sorted BST order is maintained
public void add(T value)
	{
	        overallRoot = add(overallRoot, value);
	}

// Adds the value to the given subtree.  Does not add duplicates.
// A node's initial state is passed in and its modified 
// state is returned.  This is the x = change(x) pattern and
// it allows attaching new nodes to the tree.
private IntTreeNode<T> add(IntTreeNode<T> root, T value)
{
	if (root == null)
	{
		root = new IntTreeNode<T>(value);
	} 
	else if (value.compareTo(root.data) < 0)
	{
		root.left = add(root.left, value);
	}
	else if (value.compareTo(root.data) > 0)
	{
		root.right = add(root.right, value);
	}
	return root;
}//end of private add method
Sorry if Im leaving out something needed, Im bad at posting code
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-04-2012 , 01:46 PM
The 2012 QuakeCon keynotes from John Carmack were put up recently:

http://www.youtube.com/watch?v=wt-iVFxgFWk

It's a 3 hour discussion on game programming challenges and the current + future status of virtual reality. The near future in VR seems like it's going to be amazing. If you have about 3 hours to crush it's well worth the watch if you have an interest in programming games, gaming in general, optical technologies, display limitations/how to overcome them and virtual reality. He also briefly talks about web based gaming (streaming games vs web gl). The last 35 min or so is Q/A.

Last edited by Shoe Lace; 08-04-2012 at 02:08 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-04-2012 , 02:27 PM
Quote:
Originally Posted by PJo336
Anyone good with Java Binary Search Trees?
Solved! Turns out Im just really stupid
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-04-2012 , 10:12 PM
Quote:
Originally Posted by PJo336
Solved! Turns out Im just really stupid
algorithms are generally a really good way of exposing this .
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-05-2012 , 12:05 AM
To be honest, so does Sodoku and Android.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m