Eric Muyser http://eric.muyser.com/blog Eric Muyser news and updates Thu, 23 Feb 2012 01:14:05 GMT Thu, 23 Feb 2012 01:14:05 GMT LemonStand New Library: Moar for LESS (CSS) http://eric.muyser.com/blog/post/less-is-moar http://eric.muyser.com/blog/post/less-is-moar Sun, 09 Oct 2011 00:00:00 GMT <p>Moar is a LESS framework that was created to make slicing different types of websites and applications smoother. Get MOAR for LESS out of your CSS!</p> <p>&nbsp;</p> <p>You can find it in use here:</p> <ul> <li><a href="/blog/post/utorrent-utelevision-app/">uTelevision.app</a></li> <li><a href="http://demo.lemonstandapp.com/fresh/">Fresh Demo for LemonStand</a></li> <li><a href="/blog/post/jquery-ui-theme-cocoa/">Cocoa theme for jQuery</a></li> </ul> <p>&nbsp;</p> <p><strong>Links</strong></p> <ul> <li><a href="https://github.com/ericmuyser/moar/zipball/master">Download</a></li> <li><a href="https://github.com/ericmuyser/moar">Source &amp; Documentation</a></li> <li><a href="https://github.com/ericmuyser/moar/issues">Having issues?</a></li> </ul><p>Posted in: <a href="http://eric.muyser.com/blog/category/programming">Programming</a></p> Tip: Getting error "unrecognized selector sent to instance"? http://eric.muyser.com/blog/post/tip--getting-error--unrecognized-selector-sent-to-instance http://eric.muyser.com/blog/post/tip--getting-error--unrecognized-selector-sent-to-instance Tue, 21 Jun 2011 00:00:00 GMT <p>So you are developing an Appcelerator app, and you've across this mysterious error. At least, that's what I'm assuming as you've come across this post. From what I can tell, it tends to be predominant on iPhone/iPod. I'm not sure if my solution relates to that, being that I'm developing for the desktop.</p> <p>&nbsp;</p> <p>Basically, this error will occur when something has gone horribly wrong on the Cocoa side, which in the case of Appcelerator is out of our control. We can however stop it from showing its ugly face. For me, the major cause has been Flash related content. If I try to load a JS library such as SWFobject into my page, it will crash my app. Why? Well, let's just say I'm running Snow Leopard without hardware accelerated graphics right now, which means Flash Player 10 instantly falls on its face. I can <strong>kind of</strong> understand that from the error pointing me to OpenGL, but <strong>not really</strong>.</p> <p>&nbsp;</p> <p>For Google, the exact error I've received (which varies):</p> <p><strong>2011-06-21 21:01:38.373 utelevision[79434:b07] *** WebKit discarding exception: &lt;NSInvalidArgumentException&gt; -[FP_FPCAOpenGLLayer setBuffer:]: unrecognized selector sent to instance 0x2c8fd0</strong></p><p>Posted in: <a href="http://eric.muyser.com/blog/category/programming">Programming</a></p> New Theme: Cocoa for jQuery UI http://eric.muyser.com/blog/post/jquery-ui-theme-cocoa http://eric.muyser.com/blog/post/jquery-ui-theme-cocoa Sun, 09 Oct 2011 00:00:00 GMT <p>Cocoa-style theme for jQuery UI.</p> <p><strong><br />Links</strong></p> <ul> <li><a href="http://ericmuyser.github.com/jquery-ui-theme-cocoa/demo/">Demo</a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-theme-cocoa/zipball/master">Download</a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-theme-cocoa">Source &amp; Documentation</a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-theme-cocoa/issues">Having issues?</a></li> </ul> <p>&nbsp;</p> <address><img src="https://a248.e.akamai.net/assets.github.com/img/a66f773d9e83250628d8a26483bcb3c230f7a315/687474703a2f2f646c2e64726f70626f782e636f6d2f752f31383334333230392f62616b65722e6a7067" alt="" width="959" height="642" /></address><address><br /></address> <p>A little backstory to how this project came about. When I began development for some Appcelerator apps a few months back, I weighed the possible UI options. If you're not familiar, Appcelerator is an cross-platform application which runs your web coding as a native app on your operating system. In my case, it's essentially running my HTML/CSS/JavaScript in a WebKit frame. That meant I would need to choose 1) a CSS framework (I created my own LESS framework: <a href="https://github.com/ericmuyser/moar">moar</a>), a JavaScript framework (I created my own CoffeeScript Node.js framework, of sorts: <a href="https://github.com/ericmuyser/node-std">node-std</a> that's cross-compatible both on the server and client side, thanks to <a href="https://github.com/substack/node-browserify">node-browserify</a>), and a JavaScript UI framework to lay on top of it. Being that I was using my own JS framework, I wanted something I could simply drop in and <strong>just work</strong>.</p> <p>I explored Sproutcore, Cappuccino, and the like, but personally found them to be too much overhead for what I needed. I was fairly familiar with jQuery UI, but found creating the theme to be slightly tedious due to the raw unstructured CSS. I immediately converted the core CSS to LESS (<a href="https://github.com/ericmuyser/jquery-ui-less-theme">jquery-ui-less-theme</a> on GitHub), clearing up some of the bloat. Although it is developed in LESS, it is compiled down into raw CSS and perfectly usable in that state.</p> <p>Having used Mac OS X for a year now, I've become quite fond of the native Cocoa UI. If you go through the official jQuery UI themes, almost none of them would be suitable as a base for a Mac-style theme, but I remembered having seen <a href="https://github.com/taitems/Aristo-jQuery-UI-Theme">Aristo</a> by Tait Brown, which was an excellent theme to start with. After having finished the first version of <a href="https://github.com/ericmuyser/utelevision.app">uTelevision.app</a>, we have the first version of jquery-ui-theme-cocoa panned out.</p> <p>&nbsp;</p> <p>For those that have been paying attention, you'll notice the breakdown:</p> <ul> <li>uTelevision.app uses jquery-ui-theme-cocoa</li> <li>jquery-ui-theme-cocoa uses jquery-ui-less-theme and moar</li> </ul> <p>&nbsp;</p> <p>I'm continuing to use this theme in some currently unreleased apps, and so expect to continue to see improvements as time goes on. If you have any comments, suggestions, please let me know below. Thank you.</p> <p>&nbsp;</p> <p>More of my jQuery work can be <a href="/work/jquery">found here</a>.</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/programming">Programming</a></p> Tip: Fix Screen Tearing in Vindictus http://eric.muyser.com/blog/post/screen-tearing-in-vindictus http://eric.muyser.com/blog/post/screen-tearing-in-vindictus Wed, 23 Feb 2011 00:00:00 GMT <p>Incase anyone out there encountered this issue: Vindictus is running in windowed mode w/ no border. With my monitor, the Dell UltraSharp U2311H (E-IPS), that resulted in extreme horizontal tearing. In order to fix it you need to manually override the "default" settings in your Graphic Options to use fullscreen. However, and this may explain why they are doing that, that caused the Auction House and all other inline iframe-like areas to glitch initially. It appears what they are doing to embed inline websites (probably webkit too) into the game is causing an issue in fullscreen, and it's either causing a glitch or temporarily switching to windowed mode when you initiate the AH, etc.</p> <p>&nbsp;</p> <p>Interesting, anyway, happy gaming!</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/gaming">Gaming</a></p> Getting started with Nginx, PHP5, and MySQL http://eric.muyser.com/blog/post/getting-started-with-nginx--php5--and-mysql http://eric.muyser.com/blog/post/getting-started-with-nginx--php5--and-mysql Tue, 22 Feb 2011 00:00:00 GMT <!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; min-height: 15.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; color: #002fee} span.s1 {text-decoration: underline ; color: #002fee} span.s2 {text-decoration: underline} --> <!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial} --> <p class="p1">Today I'm going to do a quick run down from start to finish successfully installing and running PHP applications on LAMP. We'll be using Nginx, PHP5, and MySQL.&nbsp;My OS of choice is a Debian VPS; your experience may be differ on other distros.&nbsp;My host of choice is Rackspace Cloud Servers. By the end, we should be able to run web apps such as WordPress, LemonStand, Joomla, etc.</p> <p class="p1">&nbsp;</p> <p class="p1">First, we need to create our VPS. That is extremely easy on Rackspace, Linode, etc. Simply log into your backend UI and create a new server. You should be given or mailed credentials.</p> <p class="p1">&nbsp;</p> <p class="p1">You will need to point a DNS <strong>A record</strong> to the provided IP address.</p> <p class="p1">&nbsp;</p> <p class="p1">Next, we need to SSH into our box (or use a provided backend console). So we open up our command-line Console. I will assume you are using root, if not, you will need to <strong>sudo</strong> or <strong>su</strong> before each command.</p> <p class="p1">&nbsp;</p> <p class="p1">Run this command:&nbsp;<strong>ssh myusername@mydomain.com</strong> and login.</p> <p class="p1">&nbsp;</p> <p class="p1">Currently, the offered Debian version is Lenny (with Squeeze coming soon I imagine). So, in order to simplify things, we're actually going to upgrade to Squeeze.</p> <p class="p1">&nbsp;</p> <p class="p1">When I mention to edit a file, you can do so simply like this in command-line: <strong>nano /path/to/file/name.ext</strong></p> <p class="p1">If you use <strong>nano</strong>, then simply use <strong>ctrl+o</strong> to save and <strong>ctrl+x</strong> to exit.</p> <p class="p1">&nbsp;</p> <p class="p1">First, open<strong> nano&nbsp;/etc/apt/sources.list</strong>&nbsp;in your favorite editor (vi, nano, etc), change instances of <em>lenny</em> to <em>squeeze</em>, and add dotdeb's repositories, like this:&nbsp;</p> <p class="p1">&nbsp;</p> <div id="gist-840169" class="gist"> <div class="gist-file"> <div class="gist-data gist-syntax"> <div class="gist-highlight"> <pre><div id="LC1" class="line">deb http://http.us.debian.org/debian/ squeeze main contrib non-free</div><div id="LC2" class="line">deb-src http://http.us.debian.org/debian/ squeeze main contrib non-free</div><div id="LC4" class="line">deb http://security.debian.org/ squeeze/updates main contrib</div><div id="LC5" class="line">deb-src http://security.debian.org/ squeeze/updates main contrib</div><div id="LC7" class="line">deb http://php53.dotdeb.org stable all</div><div id="LC8" class="line">deb http://packages.dotdeb.org stable all</div><div id="LC9" class="line">deb-src http://php53.dotdeb.org stable all</div><div id="LC10" class="line">deb-src http://packages.dotdeb.org stable all</div></pre> </div> </div> </div> </div> <p>&nbsp;</p> <p class="p1">&nbsp;</p> <p class="p1">Then run this command:&nbsp;<strong>apt-get update</strong></p> <p class="p1">&nbsp;</p> <p class="p1">Did you get a GPG error? Check the key after the&nbsp;NO_PUBKEY and run this command:</p> <p class="p1"><strong>gpg --keyserver keys.gnupg.net --recv-key PASTE_HERE_KEY</strong></p> <p class="p1"><strong>gpg -a --export <strong>PASTE_HERE_KEY&nbsp;</strong>| sudo apt-key add -</strong></p> <p class="p1"><strong><br /></strong></p> <p class="p1">If there are two keys you may need to add two. Then run this command again:&nbsp;<strong>apt-get update</strong> (to manually update keys: <strong>apt-key update</strong>)</p> <p class="p1"><strong><strong><br /></strong></strong></p> <p class="p1">We need to create a file that will let the system know we want it to upgrade next startup:&nbsp;<strong>touch /etc/udev/kernel-upgrade</strong></p> <p class="p2">&nbsp;</p> <p class="p2">Then type <strong>reboot</strong>, and let the system shutdown. Give it a minute, and reconnect via SSH.</p> <p class="p2">&nbsp;</p> <p class="p2">Now, run this command:&nbsp;<strong>aptitude full-upgrade</strong></p> <p class="p2">&nbsp;</p> <p class="p2">To install Nginx we run this command:&nbsp;<strong>aptitude install nginx</strong></p> <p class="p2">To setup MySQL we run this command:&nbsp;<strong>aptitude install mysql-server mysql-client</strong></p> <p class="p2">To install PHP we run this command:&nbsp;<strong>aptitude install&nbsp;php5-fpm&nbsp;php5-cgi php5-dev php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ps php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-xsl php5-common php5-mysql</strong></p> <p class="p2"><strong><br /></strong></p> <p class="p1">We should enable PHP short tags, so edit&nbsp;<strong>/etc/php5/fpm/php.ini</strong>&nbsp;and change&nbsp;short_open_tag to On.</p> <p class="p1">&nbsp;</p> <p class="p1">Now, let's try restarting Nginx and PHP FPM to test, run these commands:</p> <p class="p1"><strong>/etc/init.d/php5-fpm restart</strong></p> <!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial} --> <p class="p1"><strong>/etc/init.d/nginx restart</strong></p> <p class="p1"><strong><br /></strong></p> <p class="p2">Did yours throw a warning and 2 errors as well? If so,</p> <p class="p2">1) Remove the line that starts with # hash from this file:&nbsp;<strong>/etc/php5/fpm/conf.d/ps.ini</strong></p> <p class="p2">2) Delete the extension mentioned in there error, idn.ini from the conf.d folder: <strong>/etc/php5/conf.d/idn.ini<br /></strong></p> <p class="p2">&nbsp;</p> <p class="p2">Retry restarting the services again.</p> <p class="p1">&nbsp;</p> <p class="p1">In order to get a site up and running we need to edit&nbsp;<strong>/etc/nginx/sites-available/default</strong>. When you've created your website directory, edit that file.</p> <p class="p1">&nbsp;</p> <p class="p1">In that file, duplicate the "server" definition, change the server_name to your host, like this (I've included rewrites which should work with some web software):</p> <p class="p1">&nbsp;</p> <div id="gist-840183" class="gist"> <div class="gist-file"> <div class="gist-data gist-syntax"> <div class="gist-highlight"> <pre><div id="LC1" class="line">server {</div><div id="LC2" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen 80; ## listen for ipv4</div><div id="LC4" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name mysite.com;</div><div id="LC6" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;access_log /var/log/nginx/localhost.access.log;</div><div id="LC8" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location / {</div><div id="LC9" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /home/myuser/mysite/www;</div><div id="LC10" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index index.php;</div><div id="LC11" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div id="LC12" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (-e $request_filename) {</div><div id="LC13" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</div><div id="LC14" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div id="LC16" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set $test_var true;</div><div id="LC17" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div id="LC18" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($request_method = POST) { set $test_var false; }</div><div id="LC19" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($http_X_Requested_With !~ XMLHttpRequest) { set $test_var false; }</div><div id="LC20" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div id="LC21" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($test_var = true) {</div><div id="LC22" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite ^([^.|]*[^/])$ $1/ permanent;</div><div id="LC23" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div id="LC24" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div id="LC25" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite ^(.*)$ /index.php?q=$1 last;</div><div id="LC26" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div id="LC27" class="line">&nbsp;&nbsp;&nbsp;&nbsp;</div><div id="LC28" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location ~ \.php$ {</div><div id="LC29" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fastcgi_pass 127.0.0.1:9000;</div><div id="LC30" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fastcgi_index index.php;</div><div id="LC31" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fastcgi_param SCRIPT_FILENAME /home/myuser/mysite/www$fastcgi_script_name;</div><div id="LC32" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include fastcgi_params;</div><div id="LC33" class="line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div id="LC34" class="line">}</div></pre> </div> </div> </div> </div> <p>&nbsp;</p> <p class="p2">Now reboot Nginx.</p> <p class="p2">&nbsp;</p> <p class="p2"><strong>Note:</strong> Nginx configuration files are touchy. Spaces are used as part of the syntax (the one between if and bracket for example). Use&nbsp;<strong>nginx -t</strong> to validate config syntax.<br /><strong>Note:</strong> A quick way to give full permissions when installing a web application (from within it's directory):&nbsp;<strong>chmod -R 0777 ./<br /></strong><strong>Note:</strong> As far as I can tell,&nbsp;minify has trouble converting relative URI's to absolute URI's, so you may have to hardcode the absolute path.<br /><strong>Note:</strong>&nbsp;You will likely want to take security precautions, run PHP under a different username, only give cache folders write permission, etc. That is out of the breadth of this guide; maybe in future posts or comments.</p> <p class="p2">&nbsp;</p> <p class="p2">Thanks for reading. Good luck and have fun!</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> Made with Lemon-Aid http://eric.muyser.com/blog/post/made-with-lemon-aid http://eric.muyser.com/blog/post/made-with-lemon-aid Sat, 29 Jan 2011 00:00:00 GMT <p>Welcome to the new site! I've switched from <a href="http://wordpress.org/">WordPress</a> to <a href="http://lemonstandapp.com/">LemonStand</a> (with Blog module). As you can see, I'm still under construction here, but&nbsp; I couldn't help but make the switch!</p> <p>In the coming months I'll be coding up some quick modules to improve blog functionality, such as syntax highlighting, tags, shortcodes, comment login (OpenID, Google, Twitter), and social network integration. I'll throw those up at GitHub.&nbsp;</p> <p>This theme is called Persona, and it's an unobstrusive JavaScript-based theme for LemonStand. It seems to function properly in IE and degrade gracefully with JavaScript disabled (happy coincidence).</p> <p><strong>Links</strong></p> <ul> <li><a href="http://ls-theme-persona.us.to/">Demo</a></li> <li><a href="https://github.com/ericmuyser/ls-theme-persona/zipball/master">Download</a></li> <li><a href="https://github.com/ericmuyser/ls-theme-persona">Source &amp; Documentation</a></li> <li><a href="https://github.com/ericmuyser/ls-theme-persona/issues">Having issues?</a></li> </ul> <address><br /></address><address><img src="http://dl.dropbox.com/u/18343209/Screenshots/v7jo.png" alt="" /><br /></address> <p>&nbsp;</p> <p>Shout outs to <span class="screen-name screen-name-pmeissner pill"><a href="http://twitter.com/#!/pmeissner">@pmeissner</a></span> and <a href="http://twitter.com/#!/woothemes">@woothemes</a> for the inspiration. I'm not a designer. Those fellas are <em>#great #designers</em>.</p> <p>Want to report a bug? Please post here, GitHub, Twitter,&nbsp;<a href="mailto:eric@muyser.com">eric@muyser.com</a>, or whatever you please. Thank you!</p> <p><br /><strong>Known compatibility:</strong> Firefox 3.6+, Google Chrome, Safari. <strong>Update:</strong> IE7+<br /><strong>Technology used:</strong> CSS3, HTML5, jQuery/UI, jScrollPane, scrollTo, Address, and of course custom code.<br /><strong>Fonts used:</strong>&nbsp;Ubuntu (Google Font Directory).</p> <p><br />Are you still here? Have you actually read this entire post? Amazing, you should be following me on Twitter!&nbsp;<a href="http://twitter.com/#!/ericmuyser/">Go, now!</a>&nbsp;:P</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> Tip: Fix AjaxQueue (jQuery Plugin) http://eric.muyser.com/blog/post/fix-ajaxqueue-jquery-plugin http://eric.muyser.com/blog/post/fix-ajaxqueue-jquery-plugin Sat, 28 Aug 2010 00:00:00 GMT <p>As noted by Mark Gibson in the <a href="http://api.jquery.com/queue/">.queue() docs</a>, and the <a href="http://plugins.jquery.com/project/ajaxqueue">AjaxQueue</a> tickets, the functionality of fn.queue changed and it&nbsp;is no longer working by default. In order to fix it, you need to manually call dequeue(). Simply add it after it sets up queue (line 47):</p> <p>&nbsp;</p> <pre> jQuery([ jQuery.ajaxQueue ]).queue("ajax", function(){<br /> jQuery.ajax( o );<br /> });<br /></pre> <pre><br /></pre> <pre><span style="font-family: Arial, verdana, sans-serif; font-size: 12px; white-space: normal; color: #333333; line-height: 18px;">to</span></pre> <pre><span style="color: #333333; font-family: Arial, verdana, sans-serif;"><span style="font-size: 12px; line-height: 18px; white-space: normal;"><br /></span></span></pre> <pre> jQuery([ jQuery.ajaxQueue ]).queue("ajax", function(){<br /> jQuery.ajax( o );<br /> }).dequeue("ajax");<br /><br /></pre> <p>That's it! Great plugin.. simple and effective. I may try a more robust solution in the future.</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Class: Process http://eric.muyser.com/blog/post/php-class-process http://eric.muyser.com/blog/post/php-class-process Mon, 02 Aug 2010 00:00:00 GMT <p>Here's another quick release. I remember working on this a few years ago. The idea is instead of forking processes, or calling blocking processes (with system, exec, passthru), we spawn children processes. Originally I would communicate with the actual process object, but I found a service with a process pool to be more effective (this way it can handle creation, handling, re-use, destruction, etc) - but a wrapper class could possibly be implemented. <strong>Disclaimer:</strong> I'm releasing it somewhat unfinished since I'm mostly using Python for my services these days. Feel free to fork it.</p> <p>&nbsp;</p> <p>Some examples would be handling DNS (since it's blocking) or encoding video/audio (which can take minutes) or some other command that isn't non-blocking.</p> <p>&nbsp;</p> <p>Here's a quick example that "asynchronously" downloads and prints HTML from list of URLs. Keeping your main process non-blocking and free to do other stuff.</p> <pre><br /></pre> <pre>&lt;?php<br /><br /> require_once("../src/process.php");<br /><br /> $process_service = new process_service();<br /><br /> $url_list = array(<br /> "http://google.com/",<br /> "http://facebook.com/",<br /> "http://twitter.com/"<br /> );<br /><br /> foreach($url_list as $url)<br /> $process_service-&gt;run(<br /> function() use($url)<br /> {<br /> $html = file_get_contents($url);<br /><br /> return $html;<br /> },<br /> function($html)<br /> {<br /> var_dump($html);<br /> });<br /><br /> while(true)<br /> {<br /> $process_service-&gt;update();<br /><br /> echo "."; // testing<br /> usleep(10000);<br /> }<br />?&gt;</pre> <p>&nbsp;</p> <p>1) We instantiate our <em>process_service</em><br /> 2) We have a standard array of URL's<br /> 3) We loop over those URL's, and call <em>run()</em> with 2 arguments: what you want to run in the process (anything you want from the current process in the child process must be passed with the <em>use</em> feature from <a href="http://php.net/">PHP</a> 5.3, and this works thanks to lambda serialization - credits to<a href="http://github.com/jeremeamia/super_closure"> Jeremy Lindblom's super_closure</a>), and the callback for when it's finished (arguments are whatever you returned in the first function).<br /> 4) Lastly we have a main loop which calls <em>process_service</em>'s update function, which handles IO from the children processes, and such.</p> <p>&nbsp;</p> <p><strong>Links:</strong><br /> <a href="http://github.com/ericmuyser/php-class-process/"><em>PHP Process Class</em> Source</a><br /> <a href="http://github.com/downloads/ericmuyser/php-class-process/php-class-process-2010-08-02.zip"><em>PHP Process Class</em> Download</a></p> <p>&nbsp;</p> <p>More found on the <a href="/work/">work</a> page, and more to come!</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Class: Lambda http://eric.muyser.com/blog/post/php-class-lambda http://eric.muyser.com/blog/post/php-class-lambda Sun, 23 May 2010 00:00:00 GMT <p>At the moment PHP doesn't allow serializing closures. I needed a unobtrusive solution to passing closures to child processes, which are invoked later when the child process has completed the task.</p> <p>I came across an informational article Jeremy Lindblom wrote on closures in <a href="http://php.net/">PHP 5</a> over at <a href="http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/">HTMList</a> which helped me come up with a solution to my problem. I didn't end up needing to save the serialized closure for a different process (or HTTP request), but it looks like a very interesting solution.</p> <p>For my purposes I can keep references to actual closures in the main process, and they will function exactly as they should later (including <em><strong>use</strong></em> references). An example is a cron which goes through a list of videos, spawns an FFMPEG encoding process, sends a job off to it with a lambda callback. It's all very smooth and asynchronous. Another example is a DNS checking service (since IIRC, DNS requests are not currently asynchronous in PHP).</p> <p>&nbsp;</p> <p><strong>Example:</strong></p> <pre>$a1 = array();<br /><br />$some_function_called_later(new lambda(function() use(&amp;$a1)<br />{<br /> var_dump($a1); // will contain "info" added later below<br />}));<br /><br />$a1[] = "info";</pre> <p>&nbsp;</p> <p><strong>Source:</strong></p> <pre>&lt;?php<br /><br />class resource_service<br />{<br /> public static function register(&amp;$resource)<br /> {<br /> $id = rand(0, 32768);<br /><br /> while(isset(self::$registry[$id]))<br /> $id = rand(0, 32768);<br /><br /> self::$registry[$id] = &amp;$resource;<br /><br /> return $id;<br /> }<br /><br /> public static function unregister($id)<br /> {<br /> $resource = &amp;self::$registry[$id];<br /><br /> unset(self::$registry[$id]);<br /><br /> return $resource;<br /> }<br /><br /> private static $registry;<br />}<br /><br />class lambda<br />{<br /> public function __construct(Closure $closure)<br /> {<br /> $this-&gt;closure = $closure;<br /> }<br /><br /> public function __invoke()<br /> {<br /> return call_user_func_array($this-&gt;closure, func_get_args());<br /> }<br /><br /> public function __sleep()<br /> {<br /> $this-&gt;resource_id = resource_service::register($this-&gt;closure);<br /><br /> return array("resource_id");<br /> }<br /><br /> public function __wakeup()<br /> {<br /> $this-&gt;closure = &amp;resource_service::unregister($this-&gt;resource_id);<br /> }<br /><br /> private $closure;<br />}<br /><br />?&gt;</pre> <p>&nbsp;</p> <p>More found on the <a href="/work/">work</a> page, and more to come!</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Class: cURL http://eric.muyser.com/blog/post/php-class-curl http://eric.muyser.com/blog/post/php-class-curl Fri, 07 May 2010 00:00:00 GMT <p>Here's a quick release. I've been doing a lot of scraping work lately and of course use a <a href="http://curl.haxx.se/">cURL</a> class. There's plenty of <a href="http://curl.haxx.se/">cURL</a> classes out there, and here's another. I plan on evolving the class (joining multicurl into curl) and taking advantage of <a href="http://php.net/">PHP</a> 5.3 lambdas.</p> <pre><br /></pre> <pre>&lt;?php<br /><br />require_once("../src/curl.php");<br /><br />$session = new curl();<br /><br />$m1 = new curl_request();<br />$m1-&gt;set_url("http://google.com/");<br /><br />$r1 = $session-&gt;run($m1); // returns a curl_response object<br /><br />echo $r1-&gt;status_code;<br /><br />?&gt;</pre> <p>&nbsp;</p> <p><strong>[Mar 8, 2010]</strong> I've merged multicurl into the curl class. Now if you specify a callback it will assume you want asynchronous results, if you don't it will return the results synchronously as normal. I've also added the curl_request/curl_response classes which wrap common functionality. I added an example of multicurl downloading multiple pages at once. This example also uses PHP 5.3 lambda's, but isn't required (defaults to call_user_func_array in versions below 5.3).</p> <pre><br /></pre> <pre>&lt;?php<br /><br />require_once("../src/curl.php");<br /><br />$session = new curl();<br /><br />$m1 = new curl_request();<br />$m1-&gt;set_url("http://www.youtube.com/");<br /><br />$session-&gt;run($m1, function($r1) use(&amp;$session, &amp;$m1)<br />{<br /> print "[youtube] Loaded home page.\n";<br /><br /> for($i = 1; $i &lt;= 5; ++$i)<br /> {<br /> $m1-&gt;set_url("http://www.youtube.com/videos?p=" . $i);<br /><br /> $session-&gt;run($m1, function($r1) use($i)<br /> {<br /> print "[youtube] Loaded video page {$i} ({$r1-&gt;status_code}).\n";<br /> });<br /> }<br />});<br /><br />while(true)<br />{<br /> $session-&gt;update();<br /> echo "."; // debug<br /> usleep(20000);<br />}<br /><br />?&gt;</pre> <p>&nbsp;</p> <p><strong>Links:</strong><br /> <a href="http://github.com/ericmuyser/php-class-curl/"><em>PHP cURL Class</em> Source</a><br /> <a href="http://github.com/downloads/ericmuyser/php-class-curl/zipball/master"><em>PHP cURL Class</em> Download</a></p> <p>&nbsp;</p> <p>More found on the <a href="/work/">work</a> page, and more to come!</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Theme: Stoke Games http://eric.muyser.com/blog/post/wordpress-theme-stokegames http://eric.muyser.com/blog/post/wordpress-theme-stokegames Sat, 16 Jan 2010 00:00:00 GMT <p>Here's a minimalistic <a href="http://wordpress.org/">WordPress</a> theme I've been working on. I still have to get around to the final touches (padding, margins, widgets, etc).</p> <p><img class="aligncenter size-full wp-image-197" title="stokegames" src="http://eric.muyser.com/wp-content/uploads/2010/01/stokegames.jpg" alt="" width="500" height="250" /></p> <p>&nbsp;</p> <p><strong>Links:<br /></strong><a href="http://stokegames.com/">Stoke Games Demo</a><br /> <a href="http://github.com/downloads/ericmuyser/wordpress-theme-stokegames/wordpress-theme-stokegames.zip">Stoke Games Download</a><br /> <a href="http://github.com/ericmuyser/wordpress-theme-stokegames/">Stoke Games Source</a></p> <p>&nbsp;</p> <p>More Wordpress themes can be found on the <a href="http://eric.muyser.com/work/">work page</a>.</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Website: Battle.net Database http://eric.muyser.com/blog/post/bnetdb http://eric.muyser.com/blog/post/bnetdb Mon, 18 Feb 2008 00:00:00 GMT <p>As I've grown tired of <a title="Battle.net" href="http://battle.net/">Battle.net</a>'s game list feature, I've developed a web-based replacement. It only shows a fraction of the current games (at least, if there's more than 10 or so). It's very limited, and game's which you know exist either will not show up or will disappear from the list within a few seconds. To my surprise no one had come up with an improved game search. The project idea came to me when I was doing similar web development work in 2008. I wasn't aware at the time, but there did exist d2loader and <a title="Redvex" href="http://redvex.d2help.com/">Redvex</a> plugins that allowed game filtering. This is very similar, but it keeps track of past and present games via an online interface. <a title="Battle.net Database" href="http://bnetdb.com/">BNDB</a> is a fancy name for a few very simple scripts.</p> <p>&nbsp;</p> <address><img src="http://dl.dropbox.com/u/18343209/Screenshots/y29x.png" alt="" /></address> <p>&nbsp;</p> <p>I started with a Python proxy script that monitored packets from my <a href="http://www.blizzard.com/diablo2/">Diablo 2</a> client. Unfortunately, that made it difficult to have D2 up and running 24/7, let alone multiple instances for each realm, difficulty, etc. I have since moved over to a slightly modified version of the clientless library, heroin glands. Now I can have my *nix server run a very low resource application that updates all the game lists.</p> <p>In total there are 144 different game lists for <a title="Diablo 2" href="http://www.blizzard.com/diablo2/">Diablo 2</a>. Each realm, difficulty, ladder/non-ladder, softcore/hardcore has it's own list of games. In order for each one to work, I need a character which can access the chosen list. Normal difficulty characters are easy, but I don't have time to get rushed to Nightmare/Hell on 100 different settings. For this reason, plugins and desktop applications seem a more logical solution than <a href="http://bnetdb.com/">BNDB</a>, however this was an interesting project none-the-less.</p> <p><strong>Enabled Lists:</strong><br /> D2 LoD USWSCL Normal</p> <p><strong>143 Disabled Lists</strong></p> <p>If you want a list enabled, please leave a comment. If you want to donate a character for a certain game list, please send me the account name and password to eric.muyser@gmail.com and I will see about enabling that game list.</p> <p><strong>Example Searches:</strong></p> <ul> <li>baal</li> <li>free</li> <li>pk</li> <li>bring ist</li> <li>brg</li> <li>duel</li> <li>d u e l</li> <li>scr</li> <li>shako</li> <li>mal</li> </ul> <p>Anyone that wants to use it, hope it's helpful. :) A modern browser such as <a href="http://www.mozilla.com/firefox/">Firefox</a> is recommended.</p> <p>Feedback, bugs, requests, etc. appreciated.</p> <p>I may or may not create a <a href="http://redvex.d2help.com/">Redvex</a> plugin that works together with a <a href="http://qt.nokia.com/">Qt</a> application to filter the game list using the <a title="Battle.net Database" href="http://bnetdb.com/">BNDB</a> API, so it would come up as shown on the website. It really depends.</p> <p>The images are copyright <a title="Blizzard Entertainment" href="http://www.blizzard.com/">Blizzard Entertainment</a>, modified from <a href="http://www.blizzard.com/diablo2/">Diablo 2</a> screenshots.</p> <p>&nbsp;</p> <p><strong>Links:</strong><br /> <a href="http://bnetdb.com/">Battle.net Database Website</a><br /> <a href="http://github.com/ericmuyser/bnetdb/">Battle.net Database Source</a></p> <p>&nbsp;</p> <p><strong>Todo:</strong><br /> - Enable more game lists. I have to convert some heroin to my own asynchronous library before-hand.<br /> - Improve the site JS and add features such as dates and player lists.<br /> - Cookies to save UI positions.</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Script: jDrawer http://eric.muyser.com/blog/post/jquery-plugin-jdrawer http://eric.muyser.com/blog/post/jquery-plugin-jdrawer Mon, 18 Feb 2008 00:00:00 GMT <p>This jQuery plugin is based on the JavaScript "drawer" module that appeared on <a href="http://www.apple.com/downloads/">Apple</a> and <a href="http://demo.yootheme.com/">YooTheme</a>. I figured it deserved a <a href="http://jquery.com/">jQuery</a> equivalent.</p> <p><strong><br />Links:</strong></p> <ul> <li><a href="http://eric.muyser.com/scripts/jquery/jdrawer/example/">Demo</a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-drawer/zipball/master">Download</a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-drawer">Source &amp; Documentation<br /></a></li> <li><a href="https://github.com/ericmuyser/jquery-ui-drawer/issues">Having issues?</a></li> </ul> <p>&nbsp;</p> <address><img src="http://dl.dropbox.com/u/18343209/Screenshots/ym78.png" alt="" /></address> <p>&nbsp;</p> <p><strong>Sites Using jDrawer:</strong></p> <ul> <li><a href="http://meylanfitness.com/-Fitness-">Meylan Fitness</a></li> </ul> <ul> <span style="color: #333333;"><br /></span> </ul> <p>More of my jQuery work can be <a href="http://eric.muyser.com/work/jquery">found here</a>.</p> <p>&nbsp;</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Template: Generic #1 http://eric.muyser.com/blog/post/template-generic1 http://eric.muyser.com/blog/post/template-generic1 Sun, 02 Dec 2007 00:00:00 GMT <p>When I was young, I would imagine a template that when moving my mouse over an element, a description would show in a completely different section of the template (perhaps inside a crystal ball). It's slightly impractical, but at that age it sounded interesting. These days, I code more impressive scripts all the time with simple JavaScript or Flash. Now, this has nothing to do with <a href="http://www.facebook.com/">Facebook</a>, but I threw it together as a demonstration.</p> <p>This is a basic tableless layout based on <a href="http://www.facebook.com/">Facebook</a>'s layout back in 2007. When you move your mouse over an HTML element, that element is highlighted in the HTML text on the bottom of the screen. This could possibly be integrated into a layout quite nicely (think matrix effect), perhaps a smaller block with a medium opacity, but few people (ala geeks) would know what's going on when they saw it.</p> <p><img class="aligncenter size-full wp-image-261" title="facebook-preview" src="http://eric.muyser.com/wp-content/uploads/2007/12/facebook-preview.jpg" alt="" width="500" height="465" /></p> <p>&nbsp;</p> <p><strong>Links:<br /></strong><a href="http://eric.muyser.com/templates/generic1/">Generic #1 Layout Demo</a></p> <p><a href="http://eric.muyser.com/templates/generic1.zip">Generic #1 Layout Download</a></p> <p>&nbsp;</p> <p>I hope someone out there finds it helpful as a base for their own template.</p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p> New Template: Guild #1 http://eric.muyser.com/blog/post/template-guild1 http://eric.muyser.com/blog/post/template-guild1 Tue, 18 May 2004 00:00:00 GMT <p>In 2004 I was co-leader of the Remnants of Ascalon guild, for <a href="http://www.guildwars.com/">Guild Wars</a>.&nbsp;I was accepted to the alpha stage but unfortunately due to my age and location (issues with NDA) could not attend. Thus, I spent my time creating this dual fansite/guildsite for a while.</p> <p>Perhaps other guilds out there might find this template useful. Remember, it's old code, but it works. If anyone wants I still have the pages, avatars, signatures, wallpaper, etc. I developed for <a href="http://www.guildwars.com/">Guild Wars</a>. :)</p> <p><br /> <strong>Version 1</strong></p> <p><img class="aligncenter size-full wp-image-285" title="guild1-v1-preview" src="http://eric.muyser.com/wp-content/uploads/2004/05/guild1-v1-preview.jpg" alt="" width="500" height="431" /></p> <p><br /> <strong>Version 2</strong></p> <p><img class="aligncenter size-full wp-image-285" title="guild1-v2-preview" src="http://eric.muyser.com/wp-content/uploads/2004/05/guild1-v2-preview.jpg" alt="" width="500" height="220" /></p> <p>&nbsp;</p> <p><strong>Links:<br /></strong><a href="http://eric.muyser.com/templates/guild1/v2/index.php?a=guildsite&amp;guild=members">Guild #1 v2 Demo</a><br /> <a href="http://eric.muyser.com/templates/guild1/v2.zip">Guild #1 v2 Download</a><br /> <a href="http://eric.muyser.com/templates/guild1/v1/index.php?a=members">Guild #1 v1 Demo</a><br /> <a href="http://eric.muyser.com/templates/guild1/v1.zip">Guild #1 v1 Download</a></p><p>Posted in: <a href="http://eric.muyser.com/blog/category/general">General</a></p>