Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

02-15-2013 , 12:40 PM
Quote:
Originally Posted by daveT
**** writing algorithms because they make me feel stupid.

Suzzer, how accurate was my guess then?
Not super accurate. They overloaded the get function to do two completely different things.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 12:59 PM
I have a design decision to make. I'm building a clone of a sports betting website for personal use. So I can book bets for friends ldo. I'm going to get my lines from live XML feeds from either pinnacle sports or bookmaker.

Option 1 - Grab the XML feed every x minutes and update my own database. Then just query my own db whenever a user visits the site, places a bet, etc.

Option 2 - Only grab the XML when a user visits the site.

I expect to have < 10 people using the site. Option 2 will mean my site is slower because it will have to query the XML for every meaningful action, refreshing the page, placing a bet, etc. Option 1 means a faster site, but also means that my lines are slightly old. It also means I have to have this process running constantly that grabs XMLs.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 01:13 PM
option 3 - when a user visits the site, grab a local copy of the data from your own db or cache. If it's older then a threshold, go fetch a new copy and repopulate the local one.

It's kind of in between and it might work well, and then you don't need the cron job. And for small numbers of users you don't have to worry about cache stampeding too much. It also is a little better if you have navigation between various pages that all reference the same data set, in essence the user will fetch it once when they login and then use the local copy so it will be fast for the rest of a reasonable session?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 01:24 PM
Quote:
Originally Posted by suzzer99
I read up on all those different types of doing inheritance, and everyone seems to have a different solution for stuff like deep copying, performance, and adding properties that are or aren't enumerable, etc. Every time I found a method that was supposed to work, somewhere in the comments there was some major drawback. I think I'd just rather let the framework figure that out for me.

Also what do you use to make JSON calls to a REST back end server? Do I have to write my own JSON get method?
The "node" way is prototype inheritance. jsperf tests shows it's the most performant in v8 and it's easy to wrap your head around once you get used to how it works. There's plenty of examples of it in the node source code and you can safely use it on the client too because all grade A browsers support it.

To make calls to your back end you would just make an xhr. There's lots of libs to handle this because it's a bit different for IE and everyone else.

For working with json overall it's easy because it's just javascript.

json.stringify(someObject) will convert someObject to json.
json.parse(someJson) will convert someJson into an object.

On the express end all you need to serve back the json is:

res.send(someObject) in your handler, it'll take care of setting the correct headers. There's also req.xhr which is a boolean to determine if the request was an xhr or not so you can either return json back or render a server side template perhaps. This comes in really handy for progressive enhancement because you can serve the json or a template back depending on if the user has JS enabled, and doubles as also a means to have a nice JS front end while still being indexable by search engines without doing any hacks at all.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 01:29 PM
Suzzer: if it gets too weird, just use Clojure. Can't be that hard if I can figure it out.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 02:02 PM
Quote:
Originally Posted by splashpot
I have a design decision to make. I'm building a clone of a sports betting website for personal use. So I can book bets for friends ldo. I'm going to get my lines from live XML feeds from either pinnacle sports or bookmaker.

Option 1 - Grab the XML feed every x minutes and update my own database. Then just query my own db whenever a user visits the site, places a bet, etc.

Option 2 - Only grab the XML when a user visits the site.

I expect to have < 10 people using the site. Option 2 will mean my site is slower because it will have to query the XML for every meaningful action, refreshing the page, placing a bet, etc. Option 1 means a faster site, but also means that my lines are slightly old. It also means I have to have this process running constantly that grabs XMLs.
Option 2 since its probably fast enough. If its not you haven't really lost anything and can build a caching system that works for you.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 02:14 PM
Quote:
Originally Posted by Shoe Lace
I wouldn't really say it's dumb. Overloading is pretty common in every language.
plz share some examples where overloading is used to completely change the semantics of a function.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 02:24 PM
Quote:
Originally Posted by tyler_cracker
plz share some examples where overloading is used to completely change the semantics of a function.
* in C or Go is one example that stands out immediately.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 03:41 PM
I'm working on Classes and objects this week in class. I'm having a bear of a time getting everything to work together. Do you guys know of any tutorials that walk you through making classes and .h files in DevC++? I feel like most of my problems just now are IDE related, not code related (although I may eat those words).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 04:49 PM
Quote:
Originally Posted by Shoe Lace
The "node" way is prototype inheritance. jsperf tests shows it's the most performant in v8 and it's easy to wrap your head around once you get used to how it works. There's plenty of examples of it in the node source code and you can safely use it on the client too because all grade A browsers support it.

To make calls to your back end you would just make an xhr. There's lots of libs to handle this because it's a bit different for IE and everyone else.

For working with json overall it's easy because it's just javascript.

json.stringify(someObject) will convert someObject to json.
json.parse(someJson) will convert someJson into an object.

On the express end all you need to serve back the json is:

res.send(someObject) in your handler, it'll take care of setting the correct headers. There's also req.xhr which is a boolean to determine if the request was an xhr or not so you can either return json back or render a server side template perhaps. This comes in really handy for progressive enhancement because you can serve the json or a template back depending on if the user has JS enabled, and doubles as also a means to have a nice JS front end while still being indexable by search engines without doing any hacks at all.
Thanks a lot. This is great info. Do you mind if I ask what's your experience with node (what types of sites, etc)? Also have you had to deal with distributed session handing between node instances?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 05:08 PM
I have been a node hobbyist for like 2 years. I follow its progress / trends / libs and have made a number of sites.

Mostly data oriented sites where you grab a little bit of this and a little bit of that then mash it together or fairly standard CRUD sites. I also write a scraper that gathered data from various bitcoin exchanges, it ended up being half a trading bot before the market changed so drastically that my idea was not going to work.

Made a few websocket toy examples early on too (chat room) but nothing beyond thats.

Node is really good when you're not doing anything that's CPU bound because JS is kind of slow when it comes to that but "slow" is only relative to ivory tower static language benchmarks. Anytime you make a site where you're transmitting a lot of small responses you're in good shape for using node.

I have never scaled past 1 machine because honestly with a decent VPS you need serious business traffic to saturate 1 box. I know of ways to handle session management with multiple node instances though, I answered that in a previous reply.

Just dump your session data into redis and use that. Express' session middleware allows you to hook in an out of process data store without changing the API.

Use this:
https://github.com/visionmedia/connect-redis

A full example is in the express examples folder on github:
https://github.com/visionmedia/expre...ssion/redis.js

You should also check out the index.js file in that session example so you can see how it's done without Redis (but then it's in the node process). It's actually the same exact thing except you don't set the data store when you init the session middleware, couldn't be easier IMO.

If you want to utilize multiple cores in a clean way then just start up multiple node instances and load balance them, one on each core. Then use redis to store session or any other data, easy peasy.

If you don't want to complicate your stack you could use this:
https://github.com/learnboost/up

It's written partly by the guy who made express. It's a load balancer that also keeps your app running forever.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 05:12 PM
Man this backbone app is making me feel stupid. I should really sit down and learn javascript a bit better, but I get bored and would rather learn by doing.

Just started converting over to backbone marionette to help keep track of event binding/closing views. I've basically been refactoring this stupid thing for like 3 straight days and can't figure out or pin down exactly when a certain bug is happening.

Still fun though, 1 page apps are amusing.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 05:14 PM
Quote:
Originally Posted by aisflat439
I'm working on Classes and objects this week in class. I'm having a bear of a time getting everything to work together. Do you guys know of any tutorials that walk you through making classes and .h files in DevC++? I feel like most of my problems just now are IDE related, not code related (although I may eat those words).
what sort of problems are you having?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 06:23 PM
Quote:
Originally Posted by Shoe Lace
I have been a node hobbyist for like 2 years. I follow its progress / trends / libs and have made a number of sites.

Mostly data oriented sites where you grab a little bit of this and a little bit of that then mash it together or fairly standard CRUD sites. I also write a scraper that gathered data from various bitcoin exchanges, it ended up being half a trading bot before the market changed so drastically that my idea was not going to work.

Made a few websocket toy examples early on too (chat room) but nothing beyond thats.

Node is really good when you're not doing anything that's CPU bound because JS is kind of slow when it comes to that but "slow" is only relative to ivory tower static language benchmarks. Anytime you make a site where you're transmitting a lot of small responses you're in good shape for using node.

I have never scaled past 1 machine because honestly with a decent VPS you need serious business traffic to saturate 1 box. I know of ways to handle session management with multiple node instances though, I answered that in a previous reply.

Just dump your session data into redis and use that. Express' session middleware allows you to hook in an out of process data store without changing the API.

Use this:
https://github.com/visionmedia/connect-redis

A full example is in the express examples folder on github:
https://github.com/visionmedia/expre...ssion/redis.js

You should also check out the index.js file in that session example so you can see how it's done without Redis (but then it's in the node process). It's actually the same exact thing except you don't set the data store when you init the session middleware, couldn't be easier IMO.

If you want to utilize multiple cores in a clean way then just start up multiple node instances and load balance them, one on each core. Then use redis to store session or any other data, easy peasy.

If you don't want to complicate your stack you could use this:
https://github.com/learnboost/up

It's written partly by the guy who made express. It's a load balancer that also keeps your app running forever.
Learnboost have come out with some really great Node libraries, including mongoose (mongo-db) and socket.io (the industry std imo)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 06:33 PM
Quote:
Originally Posted by aisflat439
I'm working on Classes and objects this week in class. I'm having a bear of a time getting everything to work together. Do you guys know of any tutorials that walk you through making classes and .h files in DevC++? I feel like most of my problems just now are IDE related, not code related (although I may eat those words).
You are learning OO programming in C++?

May god have mercy on your soul.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 07:22 PM
Quote:
Originally Posted by Shoe Lace
* in C or Go is one example that stands out immediately.
* is an operator, not a function, but it's a fair point. i think most would agree that the double-duty of * as both pointer decorator and multiplier was not a particularly good design decision.

got an example that isn't the consequence of 40+ year-old hardware limitations?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-15-2013 , 07:38 PM
Not off the top of my head. I don't really see it as being a huge deal in this case though.

You'll see app.get('/foo', fn...) more often than not. It's instantly recognizable as it being a handler for a get request to /foo.

He could have just used getProperty and setProperty for other signature but I'm thinking that wasn't used due to it being a lot of typing and kind of redundant.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 08:07 AM
Quote:
Originally Posted by daveT
Q: Does this look like a good opportunity?

http://losangeles.craigslist.org/lac...608699867.html
Any add for "webmaster" sounds like **** imo :P
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 08:43 AM
Quote:
Originally Posted by clowntable
Any add for "webmaster" sounds like **** imo :P
Yeah, I'm a little nervous about it. 4-5 hours a week sounds incredibly low and I bet they will eventually ask for more long before this internship is up. I suspect they are just going to hire on 10 people and filter out the chuff quickly.

I'll probably do it for the sake of keeping myself busy. I don't have strong experience with PHP and I can't write js to save my life, so my chances probably aren't that good anyways, so even if it fails, I can have interviewing practice. Regardless, I'd rather have this time commitment to internship over working 40+ hours for free for 3 months any day of the week.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 08:52 AM
Quote:
Originally Posted by tyler_cracker
* is an operator, not a function, but it's a fair point. i think most would agree that the double-duty of * as both pointer decorator and multiplier was not a particularly good design decision.

got an example that isn't the consequence of 40+ year-old hardware limitations?
A prefix decorator at that!

Quiz:

Write the letter next to the corresponding symbol:

a - conditional
b - local binding
c- function definition
d- global variable
c- list
d- dictionary
e- function
f - arguments
g- if
h - else
i - and
j - or
k - calculation delimiter

() ____
() ____
() ____
() ____
() ____
() ____
() ____
() ____
() ____
() ____
() ____
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 09:57 AM
Yeah taking the job but knowing what you'll get isn't horrible. I'd focus on improving JS during that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 02:05 PM
Quote:
Originally Posted by Fubster
what sort of problems are you having?
mostly makefile drop, or MyClass.h doesn't exist. Things like that. I'm fairly certain that my issue the process that I'm using to make classes and method files.

My plan for tonight when I get home from work is to write my program in main (to ensure that it works correctly. Then, once I'm there I can cut out the class, method and main files and work through it that way.

I never used DevC++ prior to this class, I used Visual Studio. I can make objects and .h files just fine in Visual.

@gaming_mouse - thanks for your sympathy
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 02:12 PM
Just saw this and thought it was pretty cool. Cliffs: Someone found a way to run arbitrary code on a Game Boy, using only a Pokemon video game and valid controller input. You can see the result on youtube, though it's mostly boring setup work until about 10:20.

http://aurellem.org/vba-clojure/html/total-control.html

Link includes source code if you want your own clojure-based Pokemon assembler.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 03:30 PM
I cut my teeth OO on C++. One good thing is if you learn OO on C++, you learn all the gnarly aspects that most other languages either prohibit or take care of automatically – like pointer allocation, garbage collection, multiple inheritance. The problem is by the time I needed those things again, working in Objective-C - it was 10 years later and I had completely forgotten them.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
02-16-2013 , 03:37 PM
Quote:
.... is exponentiation a constant-time
instruction? In the general case, no; it takes several instructions to compute x^y
when x and y are real numbers. In restricted situations, however, exponentiation is
a constant-time operation. Many computers have a “shift left” instruction, which
in constant time shifts the bits of an integer by k positions to the left. In most
computers, shifting the bits of an integer by one position to the left is equivalent
to multiplication by 2, so that shifting the bits by k positions to the left is equivalent
to multiplication by 2^k. Therefore, such computers can compute 2^k in one
constant-time instruction by shifting the integer 1 by k positions to the left, as long
as k is no more than the number of bits in a computer word.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m