Skip to content

Instantly share code, notes, and snippets.

View cscott530's full-sized avatar

Chris Scott cscott530

  • Insider Intelligence
  • PA
View GitHub Profile
@cscott530
cscott530 / guide.md
Last active August 29, 2015 14:27
Creating EF Views

#Creating a SQL View w/ Entity Framework

This is assuming you've already gotten the SQL that drives the view written.

  1. Create an entity with the proper format (matching the columns, properties, etc., of your SQL View).
  2. Add an entry to your DbContext similar to any other entity; e.g. public DbSet<MyView> MyViews { get; set; }
  3. Run Add-Migration CreateMyViews (name is irrelevant, but try to describe what you're doing: Creating a new view).
  4. Alter the migration so that it instead creates your SQL view, Sql(@"create view MyView as (your select here)");
  • Note: put a @ before your string to allow it to run along multiple lines
  1. Run Update-Database -Force
@cscott530
cscott530 / link.js
Created September 10, 2015 19:32
Force all external links to open into a new tab
@cscott530
cscott530 / BundleConfig.cs
Last active March 31, 2016 14:15
Non-caching when EnableOptimizations won't work (Requires using Razor)
public static void RegisterBundles(BundleCollection bundles) {
//use bundles as usual
bundles.Add(new ScriptBundle("~/bundles/jqPlot/plugins")
.IncludeDirectory("~/Scripts/jqPlot/plugins", "*.js"));
}
@cscott530
cscott530 / guide.md
Last active March 3, 2020 00:05
Posting notifications to slack when an Azure deployment completes.

NOTE: You will need to be a Slack admin, and have access to create web sites, etc., in the target Azure account.

  • Go to slack, creating a new web hook.
    • Note the webhook URL (e.g. https://hooks.slack.com/services/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)
    • Set it to post the channel you'd like.
  • Go here, click deploy.
    • This adds a web-hook listening site to Azure
  • Log in to Azure and find the above site that just deployed
    • Open the Application Settings, find App Settings
  • Add slackhookuri, set its value to the above web hook URL (hooks.slack.com...)
@cscott530
cscott530 / DbContext.cs
Last active February 2, 2017 14:16
Verifying & Fix Decimal Rounding Issues
public class PomodoDbContext : DbContext, IPomodoDbContext
{
static PomodoDbContext()
{
Database.SetInitializer<PomodoDbContext>(null);
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//this should just match whatever the DB column is
modelBuilder.Entity<Invoice>()
@cscott530
cscott530 / ValidateConfig.cs
Last active January 24, 2023 14:25
Config Checker
using System.Reflection;
namespace ConfigChecker;
public class Validator
{
private NullabilityInfoContext _nullabilityContext = new NullabilityInfoContext();
public void ValidateConfig<T>(T config)
{

Converting CSS to Tailwind

  • Q: can you convert CSS to tailwind classes?
  • A: Yes, I can help you convert CSS code to Tailwind CSS classes. Please provide me with the CSS code you would like to convert, and I will do my best to assist you.
  • Q:
.sample-div {
   display: flex;
   flex-direction: column;
 padding: 1rem;