Skip to content

Instantly share code, notes, and snippets.

@thiamteck
thiamteck / gist:2324779
Created April 7, 2012 03:15
MySql random word function based on Lorem Ipsum text
DROP FUNCTION IF EXISTS random_word;
CREATE FUNCTION random_word ()
RETURNS TEXT
RETURN (ELT( FLOOR(1 + (RAND() * (100-1))),
'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'Integer', 'nec',
'odio', 'Praesent', 'libero', 'Sed', 'cursus', 'ante', 'dapibus', 'diam', 'Sed', 'nisi',
'Nulla', 'quis', 'sem', 'at', 'nibh', 'elementum', 'imperdiet', 'Duis', 'sagittis', 'ipsum',
'Praesent', 'mauris', 'Fusce', 'nec', 'tellus', 'sed', 'augue', 'semper', 'porta', 'Mauris',
'massa', 'Vestibulum', 'lacinia', 'arcu', 'eget', 'nulla', 'Class', 'aptent', 'taciti', 'sociosqu',
@thiamteck
thiamteck / gist:970297
Created May 13, 2011 10:13
JQuery validator method for checking integer that not start with zero
jQuery.validator.addMethod("numberNotStartWithZero", function(value, element) {
return this.optional(element) || /^[1-9][0-9]+$/i.test(value);
}, "Please enter a valid number. (Do not start with zero)");
@thiamteck
thiamteck / gist:877276
Created March 19, 2011 06:17
JQuery Datepicker with Month and Year only
$(document).ready(function(){
$(".monthPicker").datepicker({
dateFormat: 'mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
@thiamteck
thiamteck / gist:834867
Created February 19, 2011 06:01
JQuery, slicing long running script into batches to eliminate IE's "Stop running this script?" warning
$(document).ready(function(){
// original line that might trigger IE warning
// $(":button").button();
var $allButtons = $(":button");
var buttonCount = $allButtons.size();
var buttonized;
for(var i = 0; i < buttonCount; i = i + 100){
buttonized = applyButtons($allButtons, i, 100);