Skip to content

Instantly share code, notes, and snippets.

@jesslilly
jesslilly / logaxParserSpec.js
Created January 14, 2014 13:48
Parameterized jasmine test for your logax parser. https://github.com/jesslilly/logax. This is a really good idea to make sure that minor changes to your parser don't break your JSON output. Thanks to https://gist.github.com/basti1302/5051200 for the parameterized test gist. This test is in javascript, not coffeescript. This is a template. You wi…
var fs = require('fs');
var exec = require('child_process').exec, child;
// Inputs
var inputDir = './developer/test/unit/data/input/';
var expectedDir = './developer/test/unit/data/expected/';
var outputDir = './developer/test/unit/data/output/';
var parserA = './server/load-it/logax-a-parser.js';
var parserB = './server/load-it/logax-b-parser.js';
var inputFiles = new Array(3);
@jesslilly
jesslilly / groupBy.js
Last active January 4, 2016 03:58
Function to group an array of x,y data. Useful for charting. Requires underscore.js.
/**
* @method
* @public
* @description Take an array of objects and convert to an array of pairs whose
* xCol are grouped and yCol values are aggregated somehow. If
* grouping by day or month, dates must be in ZULU format strings!
* Original implementation returned an object with keys = xCol and
* values = yCol. It worked great but js maps(objects) cannot be
* sorted!
* @param {array}
@jesslilly
jesslilly / google-chart.html
Created January 23, 2014 15:44
Convert data used for an ngGrid (Array of same-key objects) to something that will work for a google-chart focusing on the data attribute. It would be good to refactor this code to simply take an input array and convert to google-chart format. Call groupBy externally instead.
var ngGridObj = [ {
"entity" : {
'date' : '2013-09-23 23:23:23',
'amt' : 4.5,
'name' : 'Mike'
}
}, {
"entity" : {
'date' : '2013-09-26 23:23:23',
'amt' : 6.5,
[Test]
public void GetSimilarity_SpaceInTarget_NotZero()
{
var matcher = new SimMetricsMetricUtilities.JaroWinkler();
var target = " 1 main";
var candidate = "1 main st";
var similarity = matcher.GetSimilarity(candidate, target);
var message = string.Format("Expect similarity {0} to be > .9", similarity);
Assert.IsTrue(similarity > .90, message);
@jesslilly
jesslilly / InMemorySet.cs
Last active September 26, 2017 22:12
Need to Mock a DbSet for testing Entity Framework? View the README.md file below.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
namespace FCM.Web.Tests.TestHelpers
{
@jesslilly
jesslilly / CampaignMonitor.cs
Created October 10, 2017 18:03
Get all list names and list IDs from Campaign Monitor (createsend_dotnet)
[TestMethod]
public void PrintListIds()
{
PrintListIds("key", "id");
PrintListIds("key", "id");
PrintListIds("key", "id");
}
private static void PrintListIds(string apiKey, string clientId)
{
@jesslilly
jesslilly / gist:e6ccf70736bc1a8ae9abe5afc212c1de
Created February 8, 2018 13:13
Vue Directive on show-bs-tab
Vue.directive('on-show-bs-tab', {
bind: function (el, binding) {
// This is BS4 jQuery
// When the tab is activated, load the data!
$(el).on('show.bs.tab', function (e) {
if (typeof binding.value === "function") {
binding.value.call();
}
});
}
@jesslilly
jesslilly / BuildingDbContextFactory.cs
Created April 9, 2018 13:11
Simple IDesignTimeDbContextFactory example
public class FooDbContextFactory : IDesignTimeDbContextFactory<FooDbContext>
{
public FooDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<FooDbContext>();
optionsBuilder.UseSqlServer("DeaultConnection");
return new FooDbContext(optionsBuilder.Options);
}
}
@jesslilly
jesslilly / Program.cs
Created May 22, 2018 19:54
HttpClient.cs Authentication Error?
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleTestApp1
{
class Program
{
@jesslilly
jesslilly / drop.sql
Created November 29, 2018 21:10
DROP ALL SQL SERVER TABLES
BEGIN -- Delete all tables in order to re-create.
DECLARE @sql NVARCHAR(MAX);
SET @sql = N'';
SELECT @sql = @sql + N'
ALTER TABLE ' + QUOTENAME(s.name) + N'.'
+ QUOTENAME(t.name) + N' DROP CONSTRAINT '
+ QUOTENAME(c.name) + ';'
FROM sys.objects AS c
INNER JOIN sys.tables AS t