Admun's Tech Journey

thoughts, ideas, projects, and discoveries on technologies

  • Main
  • Tag Cloud
  • Archives

24

Mar

jQuery chaining magic w/ end()

Posted by Admun  Tags: jquery, tips
It's cool to able to chain more than one action together:

$('#myTable')
.find('.firstColumn')
.css('background','red')
.end()
.find('.lastColumn')
.css('background','blue');

Meanwhile, one can make a chainable function with this:

$.fn.mySetVal = function(x,y) {
return $(this).val(x,y);
}
Leave a comment

24

Mar

Convert from 24 hours to AM/PM format in PHP

Posted by Admun  Tags: php, tips, time
I don't think there is a easier way to do it:

$ampm_time = date("g:i A", strtotime($24hr_time));
Leave a comment

16

Mar

Compare data in javascript

Posted by Admun  Tags: javascript, tips, date
To compare 2 dates in javascript actually pretty easy:

var timeFrom = new Date(from);
var timeTo = new Date(to);
if (timeFrom - timeTo > 0) {
// do something if a date range is invalid
}
Leave a comment

06

Mar

URL Validation in Javascript

Posted by Admun  Tags: javascript, regex, tips
I was recently searching on-line for how to do URL validation in Javascript. The best one I found so far is this:

url = 'http://somewhere.com';
var rx = new RegExp();
rx.compile(/http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/);
if (rx.test(url)) {
doSomethingForURL();
}
Leave a comment

About Me

admun My passion has always been on software development, and I know it since I wrote my first program on an Apple II. I worked on cellular wireless system in the past (C/C++) and now focus on web application (LAMP, PHP, MySQL, CakePHP, Symfony, jQuery, Google AppEngine/python).

Tags

abit android apache app engine audio bandwidth benchmark bing blogroll bluetooth boinc bookmark botnet bt cakephp cdma cellphone chinese chrome clouds coding crash crawler date dns drm dsl fedora friendster g1 gaim gdesklets gmail google grid h323 hardware html ie6 instant messaging internet javascript jquery language lifestreaming linux liunx meetup ming motorola msi mysql nas nat networking nokia ntp nucleus opinion optimization os p2p palm parrot php power reblog redhat regex rss sdk se search security shell skype social network spam stats string svn syntax sysadmin t-mobile teksavvy telecom thinkpad time tips tuning tv twitter unix voip web web app web2.0 webos wordpress

Archives

  • Full archive
  • May, 2013
  • Feb, 2013
  • May, 2012
  • Aug, 2011

Search

Powered by LMNucleus CMS v3.66 | Copyright Edmond Hui
This page takes 0.055 sec/31 queries to process | NP_BadBehavior blocked 334 spams for the past 7 days
Theme Design by short funny jokes | Ported to Nucleus CMS by BABOCHTA
[Valid XHTML 1.0 Strict]