Skip to content

Instantly share code, notes, and snippets.

View andrewjamesford's full-sized avatar

Andrew Ford andrewjamesford

View GitHub Profile
@andrewjamesford
andrewjamesford / gist:1788793
Created February 10, 2012 11:04
Auto refresh div via jQuery every 10 seconds
var auto_refresh = setInterval(
function () {
$('#voteListing ul').load('/home/listing').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
@andrewjamesford
andrewjamesford / gist:1866649
Created February 20, 2012 00:01
C# Convert int? to int
int value = (nullableValue.HasValue) ? nullableValue.Value : 0 ;
@andrewjamesford
andrewjamesford / dabblet.css
Created February 28, 2012 21:03
CSS for iOS button notification
/** iOS button notification
* The first commented line is your dabblet’s title
*/
body{
min-height:100%;
font-family: Verdana,sans-serif;
}
.notificationCont {
position: relative;
@andrewjamesford
andrewjamesford / script.js
Created March 11, 2012 19:44
Code to invoke AJAX spinner using spin.js
var spinner;
function FireSpinner() {
var opts = {
lines: 12, // The number of lines to draw
length: 12, // The length of each line
width: 7, // The line thickness
radius: 23, // The radius of the inner circle
color: '#fff', // #rgb or #rrggbb
speed: 1, // Rounds per second
@andrewjamesford
andrewjamesford / gist:2793161
Created May 26, 2012 09:43
Disable default appearance of input elements in WebKit and iOS
input[type="search"] {
-webkit-appearance: textfield;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
display: none;
}
@andrewjamesford
andrewjamesford / gist:2878228
Created June 5, 2012 21:38
jQuery Modular Template
var ModuleName = {
init: function () {
this.cacheElements();
this.bindEvents();
},
cacheElements: function () {
this.$elementName = $('#element');
},
bindEvents: function () {
this.$elementName.on('click', this.methodName)
@andrewjamesford
andrewjamesford / gist:2879742
Created June 6, 2012 03:38
Time validation in ASP.Net MVC using a regular expression
[DisplayFormat(ApplyFormatInEditMode = true,DataFormatString = "{0:HH:mm}")]
[RegularExpression(@"^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$", ErrorMessage = "Invalid time.")]
public DateTime? YourDateTime { get; set; }
@andrewjamesford
andrewjamesford / gist:2907820
Created June 11, 2012 00:19
Table Row count in Razor
<table>
@{
int Count = 0;
}
@foreach (var item in Model)
{
<tr data-row="@Count">
<td></td>
<td></td>
<td></td>
@andrewjamesford
andrewjamesford / singleton-jquery-pattern.js
Last active September 30, 2017 15:28
jQuery singleton boilerplate
var App = ( function () {
return {
init: function() {
this.cacheElements();
this.bindEvents();
},
cacheElements: function() {
this.$myid = $('#myid');
},
bindEvents: function() {
@andrewjamesford
andrewjamesford / gist:4137872
Created November 24, 2012 00:51
Test code for Rich Text Editors
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<p>Lorem ipsum dolor sit amet, <strong>bold</strong> adipiscing elit. Nunc molestie ipsum sit amet sem. Praesent dictum malesuada metus. Mauris pharetra ligula <strong>strong</strong> eget erat. Vestibulum ante <em>italic</em> ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur ultrices. Vestibulum ante ipsum primis in faucibus orci luctus et <a href="#">link</a> ultrices posuere cubilia Curae; Praesent convallis dolor ut dui. Phasellus justo arcu, dignissim ac, sodales ac, sagittis in, leo. Sed volutpat, urna ut eleifend elementum, sem est gravida nisl, sit amet venenatis ante turpis vel augue. Fusce placerat pulvinar risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Integer nec quam a libero commodo blandit. Vivamus nibh velit, gravida sit amet, pretium ut, blandit vel, turpis. Aenean non odio. Vivamus enim. Cras <u>underline</u> sodales vu