Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark McFadden m2web

View GitHub Profile
@m2web
m2web / gist:057d156dfd31ad3e4af1
Last active Aug 29, 2015
C# NUnit Test Except And Intersect
View gist:057d156dfd31ad3e4af1
[Test]
public void TestExceptAndIntersect()
{
//check if equal with differing sequence
var list1 = new List<int>(new int[] { 1, 2, 3, 4, 5, 6 });
var list2 = new List<int>(new int[] { 6, 5, 4, 3, 2, 1 });
var result = list1.Except(list2).ToList();
Assert.AreEqual(new int[] { }, result);
@m2web
m2web / jQuerySortableTable.html
Last active Dec 29, 2015
Example code of jQuery Sortable Table Rows
View jQuerySortableTable.html
<!DOCTYPE html>
<html>
<head>
<title>Soratble Table Rows</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
</head>
<body>
<table border="1" id="formTable">
<thead><th>View</th><th>Page</th><th>Sheet #</th><th>Reason</th><th>Location</th></thead>
<tbody id="sortThis">
@m2web
m2web / Example Selenium.html
Created Jul 22, 2013
Example Selenium HTML Test Code for Selenium IDE
View Example Selenium.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<tr>
<td>type</td>
<td>j_username</td>
@m2web
m2web / replaceAll.js
Created Jul 9, 2013
JavaScript replaceAll example
View replaceAll.js
var name = "John Jacob Jingleheimer Smith";
//replace the space with a dot '.'
var id = name.replace(/\s/g, '.');
console.log(id);
//now replace the '.' with a space
newId = id.replace(/\./g, ' ');
console.log(newId);
@m2web
m2web / SpecRunner.htmlIncludes.html
Created Jun 27, 2013
Jasmine SpecRunner.htmlIncludes.html
View SpecRunner.htmlIncludes.html
<!-- include source files here... -->
<script type="text/javascript" src="src/DateSort.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/DateSortSpec.js"></script>
@m2web
m2web / DateSortSpec2.js
Created Jun 27, 2013
Jasmine DateSortSpec2.js
View DateSortSpec2.js
it("should show Wisdom title with descending sort", function() {
var sortedDesc = dateSort.sortedDesc(booksData);
var sortedTitle = sortedDesc[0]['title'];
expect(sortedTitle).toEqual('Wisdom');
});
@m2web
m2web / DateSortSpec1.js
Created Jun 27, 2013
Jasmine DateSortSpec1.js
View DateSortSpec1.js
describe("Sort by Date", function() {
var dateSort;
var booksData;
beforeEach(function() {
dateSort = new DateSort();
booksData = [
{
title: 'Health for a friend',
author: 'John Doe',
@m2web
m2web / DateSort2.js
Created Jun 27, 2013
Jasmine DateSort2.js
View DateSort2.js
DateSort = function (){}
DateSort.prototype.sortAsc = function(theArray){
return theArray.sort(date_sort_asc);
}
var date_sort_asc = function(a,b){
a = new Date(a.publishDate);
b = new Date(b.publishDate);
return a<b ? -1 : a>b ? 1 : 0;
@m2web
m2web / DateSort1.js
Created Jun 27, 2013
Jasmine DateSort1.js
View DateSort1.js
DateSort = function (){}
DateSort.prototype.sortAsc = function(theArray){
return "";
}
@m2web
m2web / DataSort3.js
Last active Dec 19, 2015
DateSort steps with Jasmine
View DataSort3.js
DateSort.prototype.sortedDesc = function(theArray){
return theArray.sort(date_sort_desc);
}
var date_sort_desc = function(a,b){
a = new Date(a.publishDate);
b = new Date(b.publishDate);
return a<b ? 1 : a>b ? -1 : 0;
};
You can’t perform that action at this time.