Category: code

  • TextMate – Search in project

    Several issues I would suggest to the developer: 1) When searching, there is no status/progress indicator (or the button flashing very lightly that I do not notice, but a turning icon would be much nicer). For a large project with over 1000 files, one would wonder if these are all the result or it’s still…

  • First snippet customization in TextMate

    After reading the manual and view the bundle, customization is quite powerful in TextMate. This class declaration should be trigger by typing “class”, then press Tab key. It automatically your full name using finger/whoami and set the date. Pretty neat eh! /** * ${4:Description} * @package ${5:default} * @version \$Id\$ * @since `date` * @author…

  • CakePHP – Simple User Registration

    After doing some initial readings on different PHP frameworks, including CakePHP, CodeIgniter, Symphony, Zend. I’m digging deeper into CakePHP with an open eyes for fresh ideas and other developments. To start, CakePHP is slow, quite slow (backed up by Rasmus’s benchmark at froscon). It also has not taken advantage of more object-oriented syntax and methods.…

  • Related keywords & spelling suggestion API

    Google Toolbar Auto Complete Replace your own “q=keywords”: http://google.com/complete/search?output=toolbar&q=Ad+Server Google SOAP Search API http://scholar.google.com/apis/reference.html#1_3 Yahoo Related Keywords API http://developer.yahoo.com/search/web/V1/relatedSuggestion.html Yahoo Spelling Suggestion API http://developer.yahoo.com/search/web/V1/spellingSuggestion.html

  • Check username availability via AJAX with jQuery

    HTML Checking… JavaScript $(“#loading”).hide(); var orig=$(“#loading”).html(); $(“#UserNameInputID”).blur(function() { $(“#loading”).html(orig); $(“#loading”).show(); loadTextPage(“loading”,”check.php?username=”+$(“#UserNameInputID”).val()); }); /** load a text page into this div */ function loadTextPage($pDivID,$pURL) { $.ajax({ url:$pURL, dataType:’html’, success:function (txt) { $(‘#’+$pDivID).html(txt); } }); Server-side check.php

  • jQuery eq() typical mistake

    With all the open/close quote, you might write this code: var i = 123; $(“:checkbox:eq(i)”).removeAttr(“disabled”); Since the selector string is within the quotes, the correct statement should be: $(“:checkbox:eq(“+i+”)”).removeAttr(“disabled”);

  • Linear Regression PHP Class

    This PHP 5 class accepts an array of data as input, performs linear regression analysis and returns the trend line. The result is the same as in Excel (Tools/Data Analysis/Regression) Sample Usage // sales data for the last 30 quarters $vSales = array( 637381,700986,641305,660285,604474,565316,598734,688690,723406,697358, 669910,605636,526655,555165,625800,579405,588317,634433,628443,570597, 662584,763516,742150,703209,669883,586504,489240,648875,692212,586509 ); $vRegression = new CRegressionLinear($vSales); $vNextQuarter = $vRegression->predict(); //…