Skip to content

Instantly share code, notes, and snippets.

View cgorshing's full-sized avatar
👋
Hey!

Chad Gorshing cgorshing

👋
Hey!
View GitHub Profile
@cgorshing
cgorshing / gist:1100171
Created July 22, 2011 19:09
jQuery Confirm Dialog (noConflict)
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#deleteLink').click(function() {
return jQueryConfirm('#deleteLink', '<fmt:message key="buttons.delete.confirm"/>', 'Delete', 'Cancel');
});
});
function jQueryConfirm(id, message, confirmButton, cancelButton) {
var dialog = jQuery('<div></div>');
Turned this ....
private void BindViews()
{
var associatedTable = new DataTable();
associatedTable.Columns.Add(new DataColumn("TestID", typeof (Int32)));
if (_onlineCourse != null && _onlineCourse.OnlineCourseID > 0)
{
foreach (OnlineCourseTest oct in OnlineCourseTest.GetAllByOnlineCourseID(_onlineCourse.OnlineCourseID))
associatedTable.Rows.Add(new object[] {oct.TestID});
@cgorshing
cgorshing / groovy-pom.xml
Created May 16, 2012 14:26
Bare bones Groovy Pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>project-name</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@cgorshing
cgorshing / gist:3415982
Created August 21, 2012 14:25
Read Fixed Width File w/Excel
'This script was based almost entirely on http://blogs.technet.com/b/heyscriptingguy/archive/2008/04/14/how-can-i-import-a-fixed-width-data-file-into-microsoft-excel.aspx
Const xlFixedWidth = 2
'http://msdn.microsoft.com/en-us/library/office/bb241018(v=office.12).aspx
Const xlDMYFormat = 4 ' DMY date format.
Const xlDYMFormat = 7 ' DYM date format.
Const xlEMDFormat = 10 ' EMD date format.
Const xlGeneralFormat = 1 ' General.
Const xlMDYFormat = 3 ' MDY date format.
@cgorshing
cgorshing / hadoop-upstart
Created September 19, 2012 19:35
Beginnings of a hadoop upstart script
#http://upstart.ubuntu.com/cookbook/
#http://www.bryanmarty.com/2012/02/setting-nofile-limit-upstart/
description "Hadoop @HADOOP_DAEMON@"
author "Chad Gorshing <gorshing@gmail.com>"
start on runlevel [2345]
stop on runlevel [!2345]
env LOG_FILE="/var/log/hadoop/@HADOOP_DAEMON@.log"
@cgorshing
cgorshing / gist:3978124
Last active September 1, 2020 03:10
From /var/lib/dpkg/info/gmetad.postinst
#!/bin/sh
set -e
if ! getent group ganglia >/dev/null; then
echo Adding group: ganglia.
groupadd --system ganglia
fi
if ! getent passwd ganglia >/dev/null; then
echo Adding system user: ganglia.
@cgorshing
cgorshing / mule-examples.txt
Last active April 25, 2017 07:17
Mule Examples
<expression-component>
payload.Address1 = app.registry.encryption.decrypt(payload.Address1)
</expression-component>
<scripting:component>
<scripting:script engine="groovy" file="scripts/create-player-request-transformer.groovy"/>
</scripting:component>
<expression-component>
Runtime.getRuntime().exec("C:\\myfile.exe arg1 " + message.correlationId);
@cgorshing
cgorshing / grep.sh
Created January 22, 2014 21:46
Find a pattern with grep but only print out 5 lines above the matching line.
grep -B5 "pattern" filename | awk -F '\n' 'ln ~ /^$/ { ln = "matched"; print $1 } $1 ~ /^--$/ { ln = "" }'
package com.example;
import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;
/**
* From the docs
* "To enable the component to work directly with the message,
* you must implement the Callable interface"
*
#Functions are first
#Go to the end for the 'main' of the script
$ErrorActionPreference = "Stop"
Set-PSDebug -strict
Set-StrictMode –Version latest
$source = "Mule Monitoring"
#New-EventLog -LogName Application -Source $source
#EntryType - Valid values are Error, Warning, Information, SuccessAudit, and FailureAudit. The default value is Information.