Skip to content

Instantly share code, notes, and snippets.

@jesslilly
jesslilly / SaveAs.cs
Last active August 29, 2015 14:09
Word SaveAs
object FileName = tempFilePath;
object FileFormat = msWord.WdSaveFormat.wdFormatFilteredHTML;
object LockComments = false;
object Password = System.Reflection.Missing.Value;
object AddToRecentFiles = false;
object WritePassword = System.Reflection.Missing.Value;
object ReadOnlyRecommended = false;
object EmbedTrueTypeFonts = false;
object SaveNativePictureFormat = System.Reflection.Missing.Value;
object SaveFormsData = false;
[HttpPost]
public ActionResult ConfirmLink(string id)
{
try
{
var confirmationMessage = SomeRepo.ConfirmLink(id);
return Json(new { confirmationMessage = confirmationMessage }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
@jesslilly
jesslilly / AuditableEntity.cs
Last active August 29, 2015 14:21
Implementing a Base Class with Entity Framework
namespace My.Models.BaseModels
{
public class AuditableEntity
{
public int Id { get; set; }
public DateTime CreatedDt { get; set; }
public string CreatedBy { get; set; }
public DateTime RevisedDt { get; set; }
public string RevisedBy { get; set; }
}
@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 / README.md
Last active March 22, 2024 14:16
Deluxe Cron Job Wrapper

Cron Job Wrapper Wish List

I want a script that will give me:

  1. Logging
  2. Log purging!
  3. Email errors!
  4. Prevent duplicate processes! (flock)
  5. Source an environment file!
  6. Anything else?
[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 / 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
{