Skip to content

Instantly share code, notes, and snippets.

@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);
@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: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: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:2918567
Created June 12, 2012 16:33
Configuration Fragment for Axis2 + Rampart
<parameter name="OutflowSecurity">
<action>
<items>UsernameToken Timestamp</items>
<user>bob</user>
<passwordCallbackClass>org.apache.rampart.samples.sample03.PWCBHandler</passwordCallbackClass>
<passwordType>PasswordText</passwordType>
<addUTElements>Nonce Created</addUTElements>
</action>
</parameter>
@thiamteck
thiamteck / gist:4624687
Created January 24, 2013 16:37
Format and Mount USB Flash Drive on Raspberry Pi
sudo mke2fs -t ext3 /dev/sda1
sudo mount -t ext3 /dev/sda1 /media/usbflash/
@thiamteck
thiamteck / Axis2Attachement.java
Last active December 24, 2015 17:39
Set content type, encoding of attachment when using Axis2 to send SOAP request
//
// import these:
//
// import org.apache.axiom.attachments.Attachments;
// import org.apache.axiom.attachments.ConfigurableDataHandler;
// import javax.activation.FileDataSource
Attachments attachments = new Attachments();
ConfigurableDataHandler dh = new ConfigurableDataHandler(new FileDataSource("testing.gif")); // file path
@thiamteck
thiamteck / gist:e343066680b04a550606
Created April 29, 2015 04:27
One liner for extract public SSL cert from a server
openssl s_client -connect 127.0.0.1:443 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
@thiamteck
thiamteck / index.js
Created October 29, 2015 11:11 — forked from edokeh/index.js
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@thiamteck
thiamteck / guan-yin.js
Created October 29, 2015 11:17
guan yin
// /$$
// |__/
// /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$ /$$ /$$ /$$$$$$$
// /$$__ $$| $$ | $$ |____ $$| $$__ $$ | $$ | $$| $$| $$__ $$
// | $$ \ $$| $$ | $$ /$$$$$$$| $$ \ $$ | $$ | $$| $$| $$ \ $$
// | $$ | $$| $$ | $$ /$$__ $$| $$ | $$ | $$ | $$| $$| $$ | $$
// | $$$$$$$| $$$$$$/| $$$$$$$| $$ | $$ | $$$$$$$| $$| $$ | $$
// \____ $$ \______/ \_______/|__/ |__/ \____ $$|__/|__/ |__/
// /$$ \ $$ /$$ | $$
// | $$$$$$/ | $$$$$$/