Reputation: 1078 Grandmaster
- Active Posts:
- 6,864 (2.51 per day)
- 07-September 06
- Profile Views:
- Last Active:
- 54 minutes ago
- Viewing Board Index
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Your Car:
- Who Cares
- Dream Kudos:
Posts I've Made
Posted 7 Mar 2014What in tarnation is that contraption sonny?
Posted 7 Mar 2014Code related:
I am currently working on a to-spec HTTP/1.1 server which is coming along nicely. I am currently programming it for a single-threaded model, but I have mutex locks in place so it should be thread-safe if I ever find the need to make it multi-threaded. At this point, I am able to determine what page people are looking for, parse the headers, take the incoming content (in the case of Post at least, though it should work with Put and Delete as well), and generate a response to the incoming requests. I also found that not all browsers listen to the connection-close response right away, so I give it a small break (a few fractions of a second) and then close the connection on the server side to make sure that it is actually freed (In my testing, IE listens to the connection-close right away, but it is the only one) -- I also found that this is only really a problem with the favicon.ico file, assuming you return a 404 (doesn't exist). I still have a bit of work to accomplish on it, for instance I don't currently parse out the post/get data into key-value pairs, I just store it on the server. Further, I need to figure out how to get cookies going. Language: C++
I have also made a few JSON classes to stringify and parse JSON data/ objects according to the ECMA specification for JSON (ECMA-404 I believe). That was a fairly easy project. Language: C++
Projects in planning:
I am planning on modifying the HTTP server to allow for web sockets as well when I get that far. Language: C++
I have been paying a lot of attention to BitCoin recently, and kicking myself for not buying in to it about 6 months ago when they were significantly cheaper. I have set up a raspberry pi to be part of a mining group and am currently running about 10 GHash/s on it. Based on the math I have done it won't actually ever pay back the money it cost to get the hardware, but it is a fun little experiment in the meantime.
Last summer I helped my parents terrace their backyard. This next summer we will be continuing on that project by putting down a patio and planting something back there.
Last fall I helped my parents replace the shelving in their pantry. That was a bit of fun cutting and drilling wood and trying to make it module so we can hopefully replace parts as they break. So far it has been a lot sturdier than their previous pantry shelves were, so that's good.
Posted 5 Mar 2014I understand that web development doesn't exactly look like something that can readily, or should normally, be done through an OOP approach to the problem; however, when you start splitting the application up in the proper ways, I find that it works out just as well, if not better, in an OO approach.
For instance, you have users. It is likely that you keep a bit of information about your users (such as what their display name is, how frequently they log in, how many Pokemon they have captured, etc) in a database somewhere, and some of that information is queried from the database every time a page loads (such as their display name, user id, and whatever else you frequently use). So that would make sense to have in an object.
Another example, if you send users emails, it can be nice to have an email object which maintains all of the variables needed to send that email, so you can do something like this:
$email = new Email(); $email->title("This is a test"); $email->to("email@example.com"); $email->from("firstname.lastname@example.org"); $email->content("Waffles"); $email->send();
As you can see, that makes sense what you are doing in each place, whereas an email using a non-OO approach may look like:
email("email@example.com", "firstname.lastname@example.org", "This is a test", "Waffles");
What is each part doing? You can't easily tell from that example without knowing either (a) what you are looking at, ( how the email function is set up, or © having variables used instead like $to which are used to try to explain the parameters going into the function.
Further, when you move in to MVC (model view controller) type of sites, having classes around to help out will speed up development. Normally I have a templating class which is responsible for taking my views and placing the user-specific (or page specific) content where it belongs. I just tell it to load a template and to put this content (dictionary) into the view and it returns the result to me.
OOP, when done properly, adds an extra layer of readability to code. You know exactly what variables and functions are associated with one another and where they are from.
Personally, I believe that an OO approach will be helpful to you in the long run.
Posted 5 Mar 2014The name "closure" annoys me. They are called all sorts of things, but of course everyone wants to have their own unique name for the same thing (anonymous functions, callbacks, lambdas, etc.). Then you have people like google who decide to release a clojure (pronounced the same way) library. Way to add to the confusion.
In short: love the feature, hate the name.
Posted 4 Mar 2014Seeing what you did with backtracking would make things a bit more easy to explain, since I for one am not familiar with the subset sum problem.
So, it looks like you can recursively break the initial set into smaller sets, and then return true or false if the subset adds to 0 and "or" them all together while unwinding to get your final answer.
- Member Title:
- #include "soul.h"
- 23 years old
- September 6, 1990
- Your mind
- Video games, programming, school.
- Full Name:
- James Blades
- Years Programming:
- Programming Languages:
- Website URL: