Skip to content

Instantly share code, notes, and snippets.

View johnw86's full-sized avatar

John Walker johnw86

View GitHub Profile
@johnw86
johnw86 / tests.txt
Last active October 2, 2019 09:02
Writing tests
// Arrange
// Act
// Assert
Naming convention
<ul>
<li ng-repeat="(key, errors) in editForm.$error track by $index"> <strong>{{ key }}</strong> errors
<ul>
<li ng-repeat="e in errors">{{ e.$name }} has an error: <strong>{{ key }}</strong>.</li>
</ul>
</li>
</ul>
/* Basic equals expression */
//Line by line
ParameterExpression pe = Expression.Parameter(typeof(Object), "x");
Expression left = Expression.Property(pe, typeof(Object).GetProperty("PropertyName"));
Expression right = Expression.Constant("value");
Expression expression = Expression.Equal(left, right);
var lambda = Expression.Lambda<Func<Object, bool>>(expression, pe);
// Short hand
@johnw86
johnw86 / disqus.js
Last active August 29, 2015 13:59
Load Disqus comments on click
/* Disqus load comments */
$('#load-comments').on('click', function (e) {
e.preventDefault();
var loadBtn = $(this);
if (!loadBtn.hasClass('disabled')) {
loadBtn.addClass('disabled');
//Remove any old errors
$("#content").find('.comments_error').remove();
@johnw86
johnw86 / JS Snippets
Created October 9, 2012 09:15
Snippets of helpful js to speed up dev
/* Faster get element by ID */
var a = $(document.getElementById("elementID"));
/* Email address regex */
^([\w-]+\.)*?[\w-]+@[\w-]+\.([\w-]+\.)*?[\w]+$
@johnw86
johnw86 / CSS Snippets
Last active October 10, 2015 02:37
Snippets of helpful css to speed up dev
/*sprite bg*/
background:url('../images/background/_sprite.png') no-repeat 0px 0px;
/*border radius - each side*/
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
/*border radius - equal sides*/
-webkit-border-radius: 5px;
border-radius: 5px;
@johnw86
johnw86 / jQuery ajax content load
Created August 13, 2012 19:58
Basic ajax Jquery script for populating list page with next items
<script>
$(function() {
$('a.more').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
//Show loading symbol
$('.loader').show();
$.get(url, function(data) {
var $data = $(data);
@johnw86
johnw86 / IE Fixes
Created June 27, 2012 13:12
Fixes for IE issues
:after in IE7
#content blockquote:after,
#content blockquote .after {
background:url('/images/background/_sprite.png');
background-position:-259px -66px;
bottom:26px;
content:'';
display:block;
height:14px;
@johnw86
johnw86 / Controller
Created May 28, 2012 19:40
Working with Google Visualizations in C# MVC and Razor
public ActionResult Index()
{
ViewBag.Data = new Bortosky.Google.Visualization.GoogleDataTable(ExampleTable()).GetJson();
return View();
}
private static DataTable ExampleTable()
{
var dt = new DataTable();
.NamedColors(@name, @color)
{
(~"body.@{name}") {
h1{
color: @color;
}
}
(~"li.@{name}"){
a{
background-image: ~'url("/media/@{name}_triangle.png")';