Jump to content

skaterdav85

Members
  • Content Count

    874
  • Joined

  • Last visited

Everything posted by skaterdav85

  1. Thanks! I found a really good article that explains it in a little more detail too. http://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html Basically I was wondering how to fine tune Apache for large spikes of traffic.
  2. Do Apache connections close once a server serves a web page for a given request? Also, if you are hosting all your static assets (JS, CSS, images, etc) on the same server as your site, how does that affect Apache connections? I was reading about the MaxClients Directive and these questions came to mind.
  3. you explained it much better JSG
  4. The code hasn't run through the PHP interpreter Save your file with a .php extension, and if you have a local web server with PHP installed, you will see the PHP code being interpreted.
  5. Interesting, thanks! I used the ReflectionMethod class instead of ReflectionProperty for my protected method, but it worked similarly.
  6. How would I use the setAccessible method in this case? Do all class members have a static method setAccessible so you can change it's access modifier on the fly?
  7. Yes, it is a logical OR. If args returns false, that expression will return arguments. If args returns true, args will be returned.
  8. Thanks JSG! I like your createDelegate method. Quite clever. In this situate I always just save this in a variable called that, which I'm sure you've seen before. It is kinda ugly especially if you have to do it in multiple methods.
  9. Well first off, why are you declaring a function called window? window is already a reserved object in the browser. Second, you will probably want to create all your instance properties/variables on the object. Right now you arent setting all those properties on your InitBuffer object. Move the following into InitBuffer and invoke it with new. this.xmlsource=objectsSource; this.indexbuffer = null; this.texelbuffer = null; this.initbuffer = InitBuffer;
  10. super interesting, thanks everyone for helping with this! EDIT: Just noticed, even though I can pass in $this using the 'use' statement, I can no longer call protected and private members. I have to make them public. I'm guessing it is because the context of the callback function is no longer in the class.
  11. In the code sample below, how do I access the value of $this inside the callback function in the hello() method? I also attached the class to this post if you want to execute it. I am getting the error: Fatal error: Using $this when not in object context I want $this to point to the current instance. class Person {public function hello() { $list = array(1, 2, 3, 4, 5); $this->iterate($list, function($num) { echo $this->multiply_by_100($num) . 'hello <br>'; });}public function iterate($list, $callback) { foreach ($list as $num) { call_user_func($callback, $num); }}public
  12. Ya I saw that about PHP 5.4. This was one tricky bug to find out. Luckily there was an extra query string parameter that I could pass to Facebook to encode large ints as strings, which is what I wanted. All the other solutions I saw used tricky regular expressions which looked nasty.
  13. skaterdav85

    json_decode

    On my local MAMP stack (PHP V 5.3.6), json_decode is taking my JSON and converting long ints to strings. On my production server (PHP V 5.3.2), json_decode is converting long ints to floats. My long ints are Facebook page ID's that looks something like: 755509932534027 I found a workaround that tells Facebook to send me long ints encoded as strings, but how can json_decode behave differently on production? Is it possible to alter the default behavior of this function? Is this common? Thanks!
  14. I did a print_r on a simplexml object and I get the following: SimpleXMLElement Object( [@attributes] => Array ( [term] => Standards [scheme] => Responsible Organization ) ) How do I access @attributes? I want to get the array element [scheme]. $root->@attributes throws a syntax error because of the @ symbol.
  15. Thanks JSG. The Cache-Control header is easier and I did: header('Cache-Control: max-age=86400'); //1 day = 86 400 seconds Also, by appending d=3_14_2012 to each request, the URL for the next day will be unique thus, not using the cache from the previous day.
  16. I just checked the Firefox extension CacheViewer and the url shows up in the cache. You can also view some of the request and response headers. This is what I see: Key: http://localhost/map2/index.php?action=Home&method=search&d=3_14_2012&searchTerm=batteryData Size: 8261 bytesFetch Count: 6Last Modified: Wednesday, March 14, 2012 5:26:22 PMLast Fetched: Wednesday, March 14, 2012 5:26:35 PMExpiration Time: Wednesday, December 31, 1969 4:00:00 PMFile on disk: none request-method: GETrequest-Accept-Encoding: gzip, deflateresponse-head: HTTP/1.1 200 OKDate: Thu, 15 Mar 2012 00:26:22
  17. I want to cache my AJAX responses for my site's search box since the data in the appilcation only changes once a day. I added the jQuery cache property and set it to true var date = new Date(), fulldate = [date.getMonth() + 1, date.getDate(), date.getFullYear()].join('_'); $.ajax({ url: 'index.php?action=Home&method=search&d='+fulldate, type: 'GET', data: data, cache: true, success: function(msg) { data.msg = msg; PS.publish('search-complete', data); }, error: function(jqXHR, textStatus, errorThrown) { console.log('Error retrieving results.') }
  18. I just started working with the Zend Framework. I've used CodeIgniter before so I'm familiar with MVC. My question is, how do I work with configuration data in a layout? I've created a layout and it works fine. I've also created a custom config.xml file in the configs folder, which holds data that will be used on the layout. Now on my layout, I have the following code which works. $news = new Zend_Config_Xml('../application/configs/config.xml', 'news'); foreach($news->feed as $key => $feed) { echo '<li class="feed" id="news_'.$key.'">'.$feed->name.'</li>';} Creating this
  19. Does anyone know the difference between a pseudo class and a pseudo element? Or do they just refer to the same thing?
  20. So I found an article that explains how to do cross domain ajax. The solution is CORS (cross origin resource sharing). http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/
  21. Great summary on the <script> element. At the bottom of that link, it does say: I'm just not sure how that is accomplished.
  22. So I tested it out, and I dont think it works. I created a simple demo on JSBin: http://jsbin.com/idodol/edit#javascript,html The demo references a script on another server and the JS script has an ajax function that tries to make a request to a php file on that other server. However, I get an error that says: XMLHttpRequest cannot load http://www-scf.usc.edu/~dtang/ajax/example1.php?name=Mike. Origin http://jsbin.com is not allowed by Access-Control-Allow-Origin.
  23. Im not referring to any specific API. I am just curious about the general process. Maybe later I will try using a JS file hosted on another server I maintain and see if it can access the server-side scripts on the same server. If not, I agree, the only way I can see data being passed back and forth is through creating script elements and passing small amounts of data as a query string through the src attribute of the script element.
  24. If you include a JS file hosted on another server, the Google Maps script for example, how does your site using that JS communicate with server side scripts hosted on other servers when cross domain AJAX isn't allowed? For example, say you include the JS file for Google Maps hosted on Google's servers onto your page which is hosted on mysite.com. When you pan the map, the script is somehow communicating with stuff on Google's servers from your your domain (mysite.com) to retrieve more map images and other relevant data. The only way I can see this being achieved is through dynamic script elem
  25. Does anyone know the difference between DOM and SAX is? I've used DOM API methods in JS before to work with XML and HTML elements. Someone recently asked me what the difference between DOM and SAX was. I haven't used SAX before (which I think is more of a Java thing). Can someone clarify? Thanks!
×
×
  • Create New...