Categories

Post under category: Code Snippets

Running jQuery in Windows 8 apps

I wrote a jQuery wrapper for the native WinJS library that is both light-weight and fast.Read the full article here: http://practicaljs.com/jquery-wrapper-for-winjs/

Javascript Querystring Parameters

Javascript Querystring Parameters

Hi all, just wrote up a javascript object to parse url parameters. You can take parameters out of the querystring or the url hash.Usage//assuming http://www.example.com/index/?foo=bar&baz=baa#test=trueurl.href; //returns http://www.example.com/index/?foo=bar&baz=baa#test=trueurl.path //return /index/?foo=bar&baz=baa#test=trueurl.get('foo'); //returns 'bar'url.get('test'); //returns trueScriptvar url = (function(){ var _href = location.href; var _path = location.pathname; var _qs = location.search.replace(/\?/, ''); var _hash = location.hash.replace(/\#/, ''); var _parse = function(string){ var params = string.split('&'); var holder = ; for(var i = 0; i < params.length; i++){ var temp = params.split('='); var key = temp; var val = Read More

XAMPP ulimit error on Mac OSX

XAMPP ulimit error on Mac OSX

If you are running XAMPP on Mac and can't start apache, you are likely getting an unhelpful error message. If the message is blank, it could be because one of your local websites doesn't have a logs folder; it could also be a hostname issue. If you are getting an error regarding ulimit and have tried the other fix on the web (commenting out the three lines related to ulimit Read More

Simplified Interface to HTML5 local storage

Simplified Interface to HTML5 local storage

Documentation & Sandbox: http://rmcvey.github.com/jsper Cart example: http://rmcvey.github.com/jsper/cart_example.htmlI decided it was time to dive into the HTML5 local storage API the other night, knowing that it has a lot of potential. There are a few problems inherent to using it, the biggest problem being lack of support in older browsers (and to a lesser degree that it is not implemented exactly the same across browsers). The other major problem I have Read More

Validating Data with Enhanced Declarative Data Integrity Rules

Validating Data with Enhanced Declarative Data Integrity Rules

Visit us at our new Google Code project page: http://code.google.com/p/metadata-validator/ Problem Definition Data validation and integrity assurance are complex subjects that have strong opinions tied to the way they are implemented. Some strongly feel that the database can handle validation using the column's attributes (size, data type, etc) and TRIGGERS/STORED PROCEDURES can provide means to enforce complex business rules. This is true, but there are many caveats and arguments against this approach. Read More

Geocoding with Google Maps and the Zend Framework

Geocoding with Google Maps and the Zend Framework

Download Example Files : Zip RAR Maps are a great way to engage your users and visualize data, but it can be a little tricky to setup. Here I will walk you through the steps needed to get a map up and running. //Sign Up Apply for a Google Maps API Key (free) here using your domain without a subdomain or www (this will allow you to use key with or without www Read More

jQuery Tabs Keyboard Shortcuts

jQuery Tabs Keyboard Shortcuts

I have integrated jQuery's UI tabs into a number of my projects and have had to significantly modify the code to achieve some goals (like being able to easily add and remove tabs. One of the simpler thing I have done with the tabbed interface is let users navigate them using keyboard shortcuts. Here is a simple snippet I use to allow users to select a tab using alt+number. I Read More

Actionscript 2.0: Centered Popup Window

Actionscript 2.0: Centered Popup Window

At some point we all need a centered popup windows. Here is a useful Actionscript 2.0 function to help get a popup window, that allows for some customization based on input parameters. Check the actual implementation at the bottom. It is also worth mentioning here, that no AS popup script will work in local testing mode. You must upload to a server (or move to a local server directory) for Read More

Alternating Table Rows with PHP

Using PHP and CSS , it's very easy to create a report-style table with alternating colors on each row. This setup assumes a connection to a MySQL database (though any supported DBMS will work), and that you have already queried your database and are ready to work with the results in your php code.CSS.norm{ color:#fff; background-color:#000; }.alt{ color:#000; background-color:#fff; }PHP Code:That's all, not much to it really.Edit: It should be stated that this could be accomplished in Read More

jQuery U.S. States Autocomplete

Yes, I looked too; but it's not out there. Here is a quick plugin I wrote utilizing the popular jQuery Autocomplete function found hereAdd it to your form element by using:<input type="text" id="state_search" /> <input type="hidden" name="state" /> ... <script type="text/javascript"> $('#state_search').states(); </script>Here is the list and the jQuery function:var state_autocomplete = [ {full:"Alabama",abbr:"AL"}, {full:"Alaska",abbr:"AK"}, {full:"Arizona",abbr:"AZ"}, {full:"Arkansas",abbr:"AR"}, {full:"California",abbr:"CA"}, {full:"Colorado",abbr:"CO"}, {full:"Connecticut",abbr:"CT"}, {full:"Delaware",abbr:"DE"}, {full:"District of Columbia",abbr:"DC"}, {full:"Florida",abbr:"FL"}, {full:"Georgia",abbr:"GA"}, {full:"Hawaii",abbr:"HI"}, {full:"Idaho",abbr:"ID"}, {full:"Illinois",abbr:"IL"}, {full:"Indiana",abbr:"IN"}, {full:"Iowa",abbr:"IA"}, {full:"Kansas",abbr:"KS"}, {full:"Kentucky",abbr:"KY"}, {full:"Louisiana",abbr:"LA"}, {full:"Maine",abbr:"ME"}, {full:"Maryland",abbr:"MD"}, {full:"Massachusetts",abbr:"MA"}, {full:"Michigan",abbr:"MI"}, {full:"Minnesota",abbr:"MN"}, {full:"Mississippi",abbr:"MS"}, {full:"Missouri",abbr:"MO"}, {full:"Montana",abbr:"MT"}, {full:"Nebraska",abbr:"NE"}, {full:"Nevada",abbr:"NV"}, {full:"New Hampshire",abbr:"NH"}, {full:"New Jersey",abbr:"NJ"}, {full:"New Mexico",abbr:"NM"}, {full:"New York",abbr:"NY"}, {full:"North Carolina",abbr:"NC"}, {full:"North Dakota",abbr:"ND"}, {full:"Ohio",abbr:"OH"}, {full:"Oklahoma",abbr:"OK"}, {full:"Oregon",abbr:"OR"}, {full:"Pennsylvania",abbr:"PA"}, {full:"Rhode island",abbr:"RI"}, {full:"South Carolina",abbr:"SC"}, {full:"South Dakota",abbr:"SD"}, {full:"Tennessee",abbr:"TN"}, {full:"Texas",abbr:"TX"}, {full:"Utah",abbr:"UT"}, {full:"Vermont",abbr:"VT"}, {full:"Virginia",abbr:"VA"}, {full:"Washington",abbr:"WA"}, {full:"West Virginia",abbr:"WV"}, {full:"Wisconsin",abbr:"WI"}, {full:"Wyoming",abbr:"WY"} ];$.fn.states = function(){ this.autocomplete(state_autocomplete,{ Read More