Skip to content

Instantly share code, notes, and snippets.

public string ConnectionString = @"Port=5432;Server=127.0.0.1;Database=eftest;UserId=dbuser;Password=dbpassword;";
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Make Blog.Url required
modelBuilder.Entity<Blog>()
.Property(b => b.url)
@badcommandorfilename
badcommandorfilename / format_uuid
Created August 9, 2016 06:15
Generate UUID with hyphens using sed and dbus-uuidgen
!#/bin/bash
dbus-uuidgen | sed 's/./-&/9;s/./-&/14;s/./-&/19;s/./-&/24'
@badcommandorfilename
badcommandorfilename / IgnoreSSLHttpClient.cs
Created August 15, 2016 05:19
.Net Core ignore ssl/X509 self-signed http request
using (var handler = new HttpClientHandler()){
handler.ServerCertificateCustomValidationCallback = delegate { return true; };
using (var httpClient = new HttpClient(handler)){
return httpClient.GetStringAsync("http://" + self.URL + "/version").Result;
}
}
@badcommandorfilename
badcommandorfilename / init.d_kestrel
Created August 25, 2016 23:17
init.d kestrel service script
#!/bin/sh
### BEGIN INIT INFO
# Provides: kestrel
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Script to run asp.net 5 application in the background
### END INIT INFO
@badcommandorfilename
badcommandorfilename / FakeDbSetMock.cs
Created January 13, 2017 01:47
Test utility to generate a an empty DbContext
internal class FakeContext
{
public static dynamic Cast(object obj, Type t)
{
if (obj is IConvertible)
{
return Convert.ChangeType(obj, t) as dynamic;
}
else
{

Scope and Purpose

What are the objectives of the system? Who are the users? What goals do the users want?

Design Inputs

What technologies will be used? What software patterns (MVVM/MVC/Pub-Sub/Producer-Consumer) are being used? What other options were considered?

System Components

Component 1

What is Component 1? What is the responsibility of Component 1?

@badcommandorfilename
badcommandorfilename / datepicker.cshtml
Created July 20, 2017 01:24
C# HTML5 input date datepicker MVC Razor
<!-- How to insert a date editor in a Razor view -->
<div class="form-group">
@Html.LabelFor(model => model.Start, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Start, new { @type="date", @class = "form-control datepicker", @Value = Model.Start.ToString("yyyy-MM-dd") } )
@Html.ValidationMessageFor(model => model.Start, "", new { @class = "text-danger" })
</div>
</div>
@badcommandorfilename
badcommandorfilename / readmore.html
Last active February 23, 2023 12:19
html html5 css read more break divider section
<!-- Pure HTML5 CSS simple "Read More" break to hide all elements after a clickable section-->
<style>
label.more {
display: inline-block;
width: 100%;
border-bottom: 1px solid black;
text-align: center;
}
@badcommandorfilename
badcommandorfilename / s3redirectlinks.xml
Created May 24, 2018 02:20
Redirect broken links from a static s3 website
@badcommandorfilename
badcommandorfilename / Base64ImgString.cs
Created May 28, 2018 00:36
Convert an ASP.NET Core image to a b64 data URL string
protected string Base64ImgString(string filepath) {
var serverpath = Path.Combine(HostingEnvironment.WebRootPath, filepath);
var contents = System.IO.File.ReadAllBytes(serverpath);
return $"data:image/png;base64,{Convert.ToBase64String(contents)}";
}