Skip to content

Instantly share code, notes, and snippets.

View tim-su's full-sized avatar

Tim Yufeng Su tim-su

View GitHub Profile
@tim-su
tim-su / gist:12271186386e70b3f3c518be6ae1e7f3
Created August 10, 2016 22:22
Shell script wait for a service up
bash -c "while ! curl -s rabbitmq:5672 > /dev/null; do echo waiting for xxx; sleep 3; done; start.sh"
bash -c "for i in {1..100} ; do if ! curl -s rabbitmq:5672 > /dev/null ; then echo waiting on rabbitmq for $i seconds; sleep $i; fi; done; start.sh"
@tim-su
tim-su / gist:bbc671f77f488ebaee17
Created September 22, 2014 06:04
postfix email server testing example
[application@rigel logs]$ telnet smtp.yonder.hubbub.com.au 25
Trying 10.210.2.50...
Connected to smtp.yonder.hubbub.com.au (10.210.2.50).
Escape character is '^]'.
220 mail1.yonder.hubbub.com.au ESMTP Postfix (2.6.6)
helo mail
250 mail1.yonder.hubbub.com.au
mail from:perf2_jasper@yarris.com
250 2.1.0 Ok
mail to: arnperf2racwa@yonder.hubbub.com.au
@tim-su
tim-su / gist:6789571
Created October 2, 2013 05:43
Jasper admin show scheduled reports
SELECT jr.label,
ju.username,
jr.report_unit_uri,
qt.trigger_type,
qt.trigger_state,
CASE WHEN qt.prev_fire_time = -1 THEN NULL ELSE (qt.prev_fire_time/86400000)+ CAST((FROM_TZ(CAST(TO_DATE('1970-01-01','YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 'UTC') AT LOCAL) AS DATE) END AS prev_fire_time,
CASE WHEN qt.next_fire_time = -1 THEN NULL ELSE (qt.next_fire_time/86400000)+ CAST((FROM_TZ(CAST(TO_DATE('1970-01-01','YYYY-MM-DD HH24:MI:SS') AS TIMESTAMP), 'UTC') AT LOCAL) AS DATE) END AS next_fire_time
FROM qrtz_triggers qt, jireportjob jr,jiuser ju
WHERE jr.ID = substr(qt.job_name,5)
and jr.owner = ju.id
@tim-su
tim-su / gist:6760261
Created September 30, 2013 07:08
Oracle see current locked tables and user/machine, etc.
select
c.owner,
c.object_name,
c.object_type,
b.sid,
@tim-su
tim-su / gist:6360565
Created August 27, 2013 23:54
curl example
#post
curl -u user:pass -X POST --header "Content-Type: application/json" -d "@surveydesign.js" --verbose http://${host}:9000/v1/app/designs
#get
curl -u user:pass --verbose http://localhost:9000/v1/app
@tim-su
tim-su / gist:6076843
Created July 25, 2013 04:09
Jquery table tr hover effects
jQuery("#survey-matrix-table tr").not(":first").hover(function() {
jQuery(this).css("background", "#F0F0F0");
}, function() {
jQuery(this).css("background", "");
});
@tim-su
tim-su / gist:6018518
Created July 17, 2013 07:40
JQuery select radio button with a certain value
$('input:radio[name="gender"]').filter('[value="Male"]').attr('checked', true);
@tim-su
tim-su / gist:5996737
Created July 15, 2013 00:26
JSP include EL for dynamic include and directive include(static)
<jsp:include page="/path/fileinc.jsp">
<jsp:param name="divId" value="div1"/>
<jsp:param name="label" value="Questions"/>
</jsp:include>
<jsp:directive.include file="/main/taglibs.jsp" />
@tim-su
tim-su / jquery-validation-radio.js
Created July 15, 2013 00:22
Write a jquery plugin extend to check if all radio buttons are checked. The extended function is tied to an element, which can be further extended to support find any other elements below "${this} element"
jQuery.fn.extend({
validateChoiceQuestions: function() {
//enhancement to select radios only under current div
//var divId = jQuery(this).attr('id');
var choiceNames = {};
jQuery('input:radio').each(function() {
choiceNames[jQuery(this).attr('name')] = true;
});
var count = 0;
jQuery.each(choiceNames, function(){
@tim-su
tim-su / gist:5863731
Last active March 12, 2024 00:22
Git snippets
git add -u
git commit -a
git push
git push -u origin master (first time push)
#also creates .gitconfig under ~
git config --global credential.helper 'cache --timeout=86400' (configure password cache for 1 day)
git config --global pull.rebase true (set pull rebase as default pull, otherwise it is pull merge and it creates merge commit)
git config --global diff.tool <scriptToCall>
git config --global merge.tool <scriptToCall>