Skip to content

Instantly share code, notes, and snippets.

View dannylloyd's full-sized avatar

Danny Lloyd dannylloyd

  • University of Arkansas for Medical Sciences
  • Cabot, Arkansas
View GitHub Profile
@dannylloyd
dannylloyd / DoubleclickPreventer.js
Created October 20, 2014 12:33
Prevents double clicking a form button after submission
$(document).on('click', '[data-prevent-doubleclick]', function() {
var $this = $(this);
// use setTimeout to let default action fire.
// setting disabled without setTimeout prevents default action
// firing
setTimeout(function() {
$this.prop('disabled', true);
});
setTimeout(function() {
$this.prop('disabled', false);
@dannylloyd
dannylloyd / IIFEVB.net.aspx
Created June 12, 2014 20:28
World's first IIFE databinding expression in VB.net!!!!!!
<asp:PlaceHolder id="PlaceHolder2" runat="server" visible='<%#
(Function()
Return Item.ProjectStatus = Web.Core.Models.ProjectProposalStatus.FullApplicationSubmitted
End Function)()%>'>
<div>Yo dog it worked</div>
</asp:PlaceHolder>
@dannylloyd
dannylloyd / Upoad.vb
Created January 22, 2014 20:35
Upload a file to SQL server database
'Database datatype should be varbinary(MAX)
FileUpload1.PostedFile.InputStream.ToByteArray()
Public Module StreamExtensions
<Extension>
Public Function ToByteArray(stream As System.IO.Stream) As Byte()
Using memoryStream = New MemoryStream()
stream.CopyTo(memoryStream)
Return memoryStream.ToArray()
@dannylloyd
dannylloyd / ArkansasStateParFixer.js
Created November 13, 2013 21:22
Parses Arkansas state park website for fun stuff to do around Arkansas Run in console on website like this www.arkansas.com/kids/stuff-to-do/map/region.aspx?r=1
$('area').each(function () {
var attri = $(this).attr('onmouseover').replace(/pop\(/g, '');
console.error(attri.split("','")[0].replace("'", ""));
console.log(attri.split("','")[1]);
});
@dannylloyd
dannylloyd / NugetBuildOutput.txt
Created November 1, 2013 21:29
Build action output nuget package
"$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -IncludeReferencedProjects -OutputDirectory "$(SolutionDir).nuget\packages" -Properties Configuration=Release
@dannylloyd
dannylloyd / openall.sh
Created October 8, 2013 13:17
Bash function that opens a bunch of browsers to the same url
function openall() {
if [[ "$1" != *http* ]]
then
set -- "http://$1"
fi
'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe' "$@";
'C:/Program Files/Internet Explorer/iexplore.exe' "$@";
'C:/Program Files (x86)/Mozilla Firefox/firefox.exe' "$@";
'C:/Program Files (x86)/Safari/Safari.exe' "$@";
}
@dannylloyd
dannylloyd / SqlServerGeographyQuery
Created September 12, 2013 18:06
Query how far a given point is from another point in meters using SQL server geography.
Dim db As New PetaPoco.Database("cs")
Dim location = Microsoft.SqlServer.Types.SqlGeography.Point("47.65100", "-122.34900", 4326)
Dim bridges = db.Fetch(Of Bridge)("select * from bridges where GpsPos.STDistance(@0) < (1609.34 * 100)")
DECLARE @currentPosition AS GEOGRAPHY = GEOGRAPHY::STGeomFromText('POINT(-122.34900 47.65100)', 4326);
SELECT *
FROM bridges
WHERE GpsPos.STDistance(@currentPosition) < (1609.34 * 100)
@dannylloyd
dannylloyd / Presence.vb
Created August 19, 2013 18:43
Get Lync Presence
Imports Microsoft.Lync.Model
Imports System.Threading
Public Class PresenceChecker
Private _contact As Contact
Dim waithandle As AutoResetEvent = New Threading.AutoResetEvent(False)
Dim state As ContactAvailability
Public Function GetUsersPresence(user As String) As ContactAvailability
@dannylloyd
dannylloyd / TraceFormatter.js
Created August 8, 2013 14:53
Formats asp.net trace information into manageable blocks. Use it like this: formatTraceInformation('Trace-Information');. Where the preferedPane is the ID of the table of information you want to see first opened.
function formatTraceInformation(preferedPane) {
var tracer = $('#__asptrace');
var traceContent = $('span.tracecontent');
//$('*', tracer).removeAttr('style');
//Removes style from trace block
//$('*', tracer).remove('style');
if (tracer.length > 0 && $('#tracer_Show').length == 0) {
$('span.tracecontent > table', tracer).each(function (index, element) {
$(element).addClass('trace-table');
@dannylloyd
dannylloyd / SQL Table to CSharp.sql
Last active September 30, 2021 19:14
SQL Table to VB Class (SQL 2000)
declare @TableName sysname;
set @TableName = 'TABLENAME';
declare @Namespace varchar(50);
set @Namespace = 'NAMESPACE';
declare @prop varchar(8000);
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
PRINT 'using System; '
PRINT 'using NPoco; '
PRINT ''
PRINT 'namespace ' + @Namespace + ' {'