Jump to content

MrFish

Members
  • Posts

    492
  • Joined

  • Last visited

About MrFish

  • Birthday 02/01/1993

Previous Fields

  • Languages
    PHP, MySQL, JavaScript, Java, NodeJS, Unix Shell

Profile Information

  • Location
    Kansas
  • Interests
    Software Architecture

Recent Profile Visitors

5,357 profile views

MrFish's Achievements

Member

Member (2/7)

9

Reputation

  1. 390 Downloads as of June 2nd. Site up with documentation: http://snoozejs.org/documentation
  2. oh shreyaskudav. You remind me of my younger self. I asked the very same question when I was 12 about booleans on the xgenstudios forums. You can always pass variables. The way programming languages work is that it always interprets the most nested elements first. So when you say- var myVar = "test";getElementById(myVar); It will interpret to getElementById("test"); first. Same with functions. function foo() { return "test";}getElementById(foo()); Interpets to- getElementById("test"); Happy programming!
  3. Javascript is a glue. It's becoming more popular as more than just a browser scripting language but it's always been a glue. You can't JUST lean javascript and do everything you want to do. Learn it along-side your server language (###### if it's nodejs more power to you) and your client language (probably html). But in technology there isn't just one language. You'l end up learning many languages to accomplish your goals.
  4. You should learn javascript, html, and css before you ask this question.
  5. I can't understand your question.
  6. shreyaskudav, You have to understand the difference between "client-side" and "server-side". A client is your computer. You see a web page and you click a button. Only your computer knows you clicked the button until you send it to the server (where your PHP lives). The server handles the request and sends a response. When a response is sent the client updates to reflect that response. Shorts of writing a working client side and serve side example there is probably a lot you need to learn if you don't understand this. Keep writing your game (that's how I learned) but you haven't got the knowledge to write it yet (let alone patients). Javascript sends (using ajax) data to your server. PHP handles the ajax request and sends a response back. AJAX updates the browser so players can see what they've done. Keep on keeping on. Good luck.
  7. This. I assume you're new to js so to do that I'd recommend going inserting new DOM nodes (cleaner imo). var myText = document.createElement("span");myText.innerHTML = "This is a note";document.getElementById("my_container").appendChild(myText); But I'd really recommend AngularJS if you're updating html. It has 2-way binding which means whenever you update a variable the view (your html) will update automatically. And whenever you update an input the controller will update. Save a lot of time and frustration.
  8. For clientHeight it really depends on your bowser. What browser are you using?
  9. I've recently been doing AngularJS work and love how it's organized. I tried to find something similar for NodeJS but after searching I've only found the basics to setup your own framework (like expressjs) but nothing that actually provides a simple modular framework. So I've started to write my own. snooze is a restful framework that is simple and modular. It's focused around building a restful api but not necessarily the nodejs version of something like apache. Every request is handled by a controller, is validated through validators, and is processed by a service. A framework suitable for web/mobile/tablet apps. snooze is released under GPL so please feel free to share, change, and share it. Also share it. Have a look at the examples and post your criticisms. I wrote this simple framework for my projects but I'm excited that it may help others. https://github.com/iamchairs/snooze https://github.com/iamchairs/snooze-stdlib snooze.module('myServer', ['snooze-stdlib']) // inject the snooze-stdlib module .route('get', '/users/:username', { // define the route controller: 'UserCtrl', // what controller should handle this route action: 'getUserByUsername', // what action to perform on this route validator: 'GetUsername' // before processing this action what validation should occur }) .controller('UserCtrl', function(User) { // inject the User service return { getUserByUsername: function(res, options) { User.getUserByUsername(options.query.username).then(function(username) { res.send(200, username); }).fail(function(err) { res.send(500, err); }); } }; }) .service('User', function($q) { // inject the $q service return { getUserByUsername: function() { var deferred = $q.defer(); deferred.resolve('iamchairs'); return deferred.promise; } }; }) .validator('GetUsername', function($validator) { // inject the validator service return function(deferred, req) { if($validator.isLength(req.query.username, 2, 32)) { deferred.resolve(); // resolve (valid request) } else { deferred.reject([400, 'Username must be between 2 and 32 characters']); // reject (invalid request) } } });
  10. Got it down to an average of 6/s per 100 business processed. Here is a list of times taken to process individual businesses. Not very consistent. Oh boy getting 146.963 queries/s average. 0.009335041046140.01928496360780.07202100753780.02311992645260.05278611183170.02507495880130.01462388038640.03662300109860.03207707405090.01911401748660.04484701156620.05123400688170.0286669731140.01086711883540.05897092819210.01087403297420.0009930133819580.00136899948120.09078907966610.0108981132507
  11. Well I've done some indexing and it's helped a lot but it's still behind. I'll post the code that runs the queries and post the queries that are called on each. # Each tag is a string value for Tag in tags: # It first checks if the tag exists in the database. # SELECT * FROM tags WHERE tag_name=%s # tag_name is indexed if self.tagExists(Tag) == False: # If not it will add the tag # INSERT INTO tags (tag_name) VALUES(%s) self.addTag(Tag) # Then it will check if the business has the tag associated to it # SELECT * FROM business_tags WHERE bt_b_id=%s AND bt_tag_id=%s # This method also searches for the business ID and tag ID given teh Business and Tag objects # This can probably be trimmed down if self.businessHasTag(B, Tag) == False: # If the business doesn't have the tag it will associate it # INSERT INTO business_tags (bt_b_id, bt_tag_id) VALUES(%s, %s) # bt_b_id is indexed self.bindBusinessTag(B, Tag) for key in B.getKeys(): # Checks if the business has this key set in the key-value data table # SELECT * FROM business_data WHERE bd_b_id=%s AND bd_key=%s # bd_b_id is indexed if self.businessHasKey(B, key): # If the business has the key it will update it # UPDATE business_data SET bd_value=%s WHERE bd_b_id=%s AND bd_key=%s self.setBusinessKey(B, key, B.get(key)) else: # If the business doesn't have the key it will insert it # INSERT INTO business_data (bd_value, bd_b_id, bd_key) VALUES (%s, %s, %s) self.addBusinessKey(B, key, B.get(key)) I am doing a lot of redundant queries when finding the business Id but this is usually less than a millisecond. I'll clean that bit up a bit. I still don't think it will be enough. I'm thinking I may need to create temporary databases and later merge them.
  12. Yes. Names are strings usually. I wish they'd all name themselves numbers but they didn't.
×
×
  • Create New...