Skip to content

Instantly share code, notes, and snippets.

View floydpink's full-sized avatar

Hari Pachuveetil floydpink

View GitHub Profile
@floydpink
floydpink / sp_open_new_window.js
Created December 5, 2012 19:45
Adding a 'Open in a new window' link on SharePoint document libraries
$(document).ready(function() {
$("td[class='ms-vb-title'] table[class='ms-unselectedtitle'] tbody tr td[class='ms-vb'] a").each(function() {
var externalWindowLink = ' <a href="' + $(this).attr("href") + '" target="_blank" title="Click here to open the link in a new window"><span style="color:green;font-size:smaller;">New Window</span></a>';
$(this).parent().append(externalWindowLink);
});
});
@floydpink
floydpink / sortDropDownListByText.js
Created December 5, 2012 19:48
Sort dropdown/select list items using jQuery
function sortDropDownListByText(dropdownlist) {
dropdownlist.children("option[value='']").remove();
// Sort all the options by text
dropdownlist.html($("option", dropdownlist).sort(function(a, b) {
return a.text === b.text ? 0 : a.text < b.text ? -1 : 1;
}));
dropdownlist.prepend(' ');
dropdownlist.children("option[value='']").attr('selected', 'selected');
@floydpink
floydpink / jQueryMap.html
Created December 5, 2012 19:52
Array.Min, Array.Max and jQuery.map()
<span id="toolbar">
<a title="Link 1" tabindex="-1" href="#"></a>
<a title="Link 1" tabindex="-2" href="#"></a>
</span>
@floydpink
floydpink / detect_jQuery.js
Created December 5, 2012 19:54
Detect jQuery
if (!$ || !$['fn']) throw new Error('jQuery library is required.');
@floydpink
floydpink / runtimeTypes.vb
Created December 5, 2012 19:55
Creating dynamic types in VB.NET
Public Function Build() As String
Dim json = String.Empty
Dim assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(New AssemblyName(_topLevelObjectName), AssemblyBuilderAccess.RunAndSave)
Dim moduleBuilder = assemblyBuilder.DefineDynamicModule(_topLevelObjectName, String.Format("{0}.dll", _topLevelObjectName))
Dim typeBuilder = moduleBuilder.DefineType(_topLevelObjectName, TypeAttributes.Class Or TypeAttributes.Public)
Dim constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public,
CallingConventions.Standard,
Nothing)
Dim constructorIL = constructorBuilder.GetILGenerator()
@floydpink
floydpink / bulk-resize-by-percent.bat
Last active October 13, 2015 15:48
Convert all JPGs in a folder to PDFs with same file name
gm mogrify -output-directory low-res -resize 60% *.png
@floydpink
floydpink / JSONKeyMinify.js
Created December 5, 2012 20:00
JSON Minification
var JSONKeyMinify = function (Array, JSON, undefined) {
"use strict";
// http://stackoverflow.com/questions/1988349/array-push-if-does-not-exist
// http://stackoverflow.com/questions/4433402/replace-keys-json-in-javascript
Array.prototype.inArray = function (comparer) {
for (var i = 0; i < this.length; i++) {
if (comparer(this[i])) return true;
}
return false;
};
@floydpink
floydpink / compare.sh
Created December 6, 2012 14:56
Compare master to experiment
git log --graph --left-right --cherry-pick --oneline master...experiment
@floydpink
floydpink / gist:4225250
Created December 6, 2012 15:21
Get git log graphically with all tags/branches
git log --all --decorate --oneline --graph
@floydpink
floydpink / lzwCompress_usage.js
Created December 7, 2012 03:17
lzwCompress.js
// To compress anything from within JS
var compressed = lzwCompress.pack(humongousObj);
// And to decompress it
var original = lzwCompress.unpack(compressed);