Skip to content

Instantly share code, notes, and snippets.

@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?
@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 / 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; }
}
[HttpPost]
public ActionResult ConfirmLink(string id)
{
try
{
var confirmationMessage = SomeRepo.ConfirmLink(id);
return Json(new { confirmationMessage = confirmationMessage }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
@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;
@jesslilly
jesslilly / treefun.js
Created November 13, 2014 14:34
Some fun with trees
window.addEventListener('load', function(e) {
var trees = new Array(3);
trees[0] = {}; // 0 0
trees[1] = {a : {}}; // 1 1
trees[2] = {a : {}, b: {a : {}, b: {a : {}, b: {}}}}; // 6 3
var nodes = function(tree) {
var count = 0;
var nodes2 = function(tree) {
@jesslilly
jesslilly / CustomJson.cs
Created June 25, 2014 15:49
JSON to C# POCO converter. I started working on this and then stopped. Saving the code in case I need it later.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Web.Helpers;
namespace Custom.Utils
{
class CustomJson
{
@jesslilly
jesslilly / FunAPI.cs
Created May 22, 2014 14:22
C# Async HttpWebRequest Console POC
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
// Assume .NET 4.5
namespace FunAPI
@jesslilly
jesslilly / Microsoft.PowerShell_profile.ps1
Last active August 29, 2015 14:01
My powershell profile
#
# vi $profile
# C:\Users\userid\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
#
new-alias vi "C:\Program Files\Sublime Text 2\sublime_text.exe"
new-alias grep select-string
@jesslilly
jesslilly / date_compare.cs
Created May 19, 2014 17:00
Different ways of comparing dates in C#
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
DateTime a = DateTime.Now;
DateTime z = DateTime.Parse("2014-06-01 00:00:00");