Skip to content

Instantly share code, notes, and snippets.

View thiyagaraj's full-sized avatar

Thiyagaraj Krishna thiyagaraj

View GitHub Profile
@thiyagaraj
thiyagaraj / port_forward.sh
Created November 14, 2011 22:33
SSH port forwarding script to access servers beyond firewalls, but accessible via "jump" servers. Run this script on the "jump" server
#!/bin/sh
#RUN this script to establish connection SSH Forwarding to HOSTNAME_HERE"
port=`netstat -an | grep 65321 | grep LISTEN | tr -s " " | cut -d" " -f 4 | cut -d"." -f 2`
if [[ $port -ne 65321 ]]
then
echo "Please Enter JUMP_SERVER Password:"
`ssh -gL 65321:HOSTNAME_HERE:22 0`
else
echo "HOSTNAME_HERE Redirect is already running on port 65321"
fi
@thiyagaraj
thiyagaraj / patch_window.console.js
Created February 15, 2012 21:25
Fix errors if window.console is not available
if (!window.console) {
window.console = {};
window.console.log = function(){};
}
@thiyagaraj
thiyagaraj / Datapower-heartbeat.js
Created February 23, 2012 17:36
DataPower Bookmarklet to prevent WebGUI from timing out
javascript:void function(){
window.setInterval("window.mainFrame.setActionScreenSubmit('displayLog', 'displayLog')", 300000);
document.bgColor='green';alert('Do NOT use this (GREEN) window, it will autorefresh and you may lose your changes\n\nPressing OK will automatically open a new window, continue working in that :)');
window.open(window.location)
}()
@thiyagaraj
thiyagaraj / print-part-page.js
Created February 27, 2012 19:45
Print part of a webpage based on id
var printPage = function(id){
var html="<html><head><title>Print page</title>";
html+="</head><body>"
html+= document.getElementById(id).innerHTML;
html+="</body></html>";
var printWin = window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
@thiyagaraj
thiyagaraj / dp-gui-console.xsl
Created March 28, 2012 18:18
WebSphere DataPower Config nodes to get input from console setting
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dp="http://www.datapower.com/extensions" xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig">
<!--
This param can be set via the DataPower GUI in the console, and it will come as input to the transformation
-->
<xsl:param name="dpconfig:paramName"/>
<dp:param name="dpconfig:paramName">
<display>Param name value</display>
<description>Param Name Description can go here</description>
</dp:param>
@thiyagaraj
thiyagaraj / xsd-any-snippet.xsd
Created May 7, 2012 16:49
wildcard snippet in xsds
<xs:element name="Something">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any processContents="lax" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute processContents="lax"/>
</xs:complexType>
</xs:element>
@thiyagaraj
thiyagaraj / highlight.js
Created June 5, 2012 15:36
Highlight text in a webpage based on keywords
keywords = ['hello world','goodbye cruel world'];
function replaceKeywords (domNode) {
if (domNode.nodeType === Node.ELEMENT_NODE) { // We only want to scan html elements
var children = domNode.childNodes;
for (var i=0;i<children.length;i++) {
var child = children[i];
// Filter out unwanted nodes to speed up processing.
// For example, you can ignore 'SCRIPT' nodes etc.
if (child.nodeName != 'EM') {
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions">
<!-- Look and say sequence in XSLT : http://en.wikipedia.org/wiki/Look-and-say_sequence -->
<xsl:template match="/">
<xsl:variable name="start" select="string('1')"/>
START: <xsl:value-of select="$start"/>
<xsl:call-template name="loop-de-loop">
<xsl:with-param name="str" select="$start"/>
<xsl:with-param name="itr" select="number(1)"/>
<xsl:with-param name="stopAt" select="number(30)"/>
@thiyagaraj
thiyagaraj / grover.c
Created October 17, 2012 03:53
Grover - A simple autonomous arduino bot - Work in progress
#include <Servo.h>
#define HEAD_SERVO_PIN 13
#define ULTRASONIC_TRIG_PIN 2
#define ULTRASONIC_ECHO_PIN 5
#define ULTRASONIC_POWER_PIN 3
#define OBSTACLE_MIN_DISTANCE 25 //in centimeter
#define MOVE_LEFT_PIN 12 //left
#define MOVE_RIGHT_PIN 11 //right
@thiyagaraj
thiyagaraj / jquery.slider.custom.step.js
Created February 4, 2014 14:38
jQuery UI slider, custom step or snap points
//This should have each valid amount that can be selected in the slider
var sliderAmountMap = [10000, 20000,30000, 40000, 45000,50000,65000];
$(function() {
$( "#slider" ).slider({
value: 4, //array index of onload selected default value on slider, for example, 45000 in same array will be selected as default on load
min: 0, //the values will be from 0 to array length-1
max: sliderAmountMap.length-1, //the max length, slider will snap until this point in equal width increments