Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View michaelbramwell's full-sized avatar

696d656b michaelbramwell

  • Perth Australia
View GitHub Profile
@michaelbramwell
michaelbramwell / GoogleClosure.aspx.cs
Created September 26, 2012 08:56
Google Closure JS Minify for C#
using System;
using System.Net;
using System.IO;
using System.Web;
/// <summary>
/// Minify js
/// Dependancy - PostSubmitter class = http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx, can easily be replaced with native http post
/// </summary>
public partial class Crown_GoogleClosure : System.Web.UI.Page
@michaelbramwell
michaelbramwell / gstFormula.cs
Created October 10, 2012 03:28
Australian GST Formula As Dollar String
public string DisplayGSTPortion { get { return string.Format("{0:C}", (Decimal)(this.TotalPriceAsDollars - (this.TotalPriceAsDollars / (decimal)1.1))); } }
@michaelbramwell
michaelbramwell / ddlCountries.aspx
Created October 11, 2012 03:04
.NET drop down list of countries
<asp:DropDownList ID="ddlCountryOrigin" runat="server">
<asp:ListItem Selected="true">Select Country</asp:ListItem>
<asp:ListItem>United States</asp:ListItem>
<asp:ListItem>Afghanistan</asp:ListItem>
<asp:ListItem>Albania</asp:ListItem>
<asp:ListItem>Algeria</asp:ListItem>
<asp:ListItem>American Samoa</asp:ListItem>
<asp:ListItem>Andorra</asp:ListItem>
<asp:ListItem>Angola</asp:ListItem>
<asp:ListItem>Anguilla</asp:ListItem>
@michaelbramwell
michaelbramwell / timePickerValidation
Created November 5, 2012 06:15
Time Picker Validation Regex Pattern
string patt = @"^\d{2}:\d{2} (AM|PM)$";
@michaelbramwell
michaelbramwell / httpErrorEventReceiver.cs
Created November 22, 2012 01:31
HTTP 404 Error WebConfig Event Receiver for Sharepoint 2010
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Security;
namespace Client.Project.Infrastructure.EventReceiver
@michaelbramwell
michaelbramwell / WidthHeightAspectRatioFormulas
Created November 29, 2012 07:17
Width / Height Aspect Ratio Formulas
New Height
original height / original width * new width = new height
New Width
orignal width / orignal height * new height = new width
@michaelbramwell
michaelbramwell / lazyLoadImgs
Created December 11, 2012 01:28
Lazy Load Function
var lazyLoadImages = function ($item) {
/// <summary>Loop over image(s) element(s) and test for data-src attribute and preload image</summary>
$item.find('img.pre-loader').each(function (index) {
var jQuerypreloaderImg = $(this);
var src = jQuerypreloaderImg.attr('data-src');
var alt = jQuerypreloaderImg.attr('alt');
var propertyImg = new Image();
$(this).hide();
@michaelbramwell
michaelbramwell / enterkey
Created December 19, 2012 03:52
jQuery func enter key
$.fn.enterKey = function (fnc) {
/// <summary>Power Search: Enter Key press</summary>
/// http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if (keycode == 13) {
fnc.call(this, ev);
}
})
@michaelbramwell
michaelbramwell / icontains
Last active December 9, 2015 21:59
jQuery icontains extension. :contains('') lowercase alt
jQuery.expr[':'].icontains = function (a, i, m) {
///<summary>Extend jQuery with case insentive contains selector</summary>
return jQuery(a).text().toUpperCase()
.indexOf(m[3].toUpperCase()) >= 0;
};
@michaelbramwell
michaelbramwell / mysqlremoteacess
Created January 4, 2013 01:41
grant remote access to mysql server from mysql shell
GRANT ALL PRIVILEGES ON {tablename}.* TO {username}@"{ipaddress}" IDENTIFIED BY "{password}"
e.g
GRANT ALL PRIVILEGES ON tableFoo.* TO wordpressuser@"192.168.1.%" IDENTIFIED BY "secure123"