Skip to content

Instantly share code, notes, and snippets.

View bcnzer's full-sized avatar

Ben Chartrand bcnzer

View GitHub Profile
@bcnzer
bcnzer / Startup.cs
Last active September 26, 2016 07:44
Example of a Startup configuration
public class Startup
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
@bcnzer
bcnzer / appsettings.json
Created September 26, 2016 08:05
Sample appsettings.json
{
"ApplicationInsights": {
"InstrumentationKey": "ABC123"
},
"ConnectionStrings": {
"DefaultConnection": "Server=BostonCreme\\donutfactorysecrets;Database=donutfactorydb;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
@bcnzer
bcnzer / project.json
Last active September 26, 2016 09:11
Snippet from project.json showing how to add Views folder
"publishOptions": {
"include": [
"wwwroot",
"Views",
"web.config"
]
},
@bcnzer
bcnzer / project.json
Created January 2, 2017 00:03
project.json with Moq
{
"dependencies": {
"dotnet-test-xunit": "1.0.0-*",
"Microsoft.AspNetCore.TestHost": "1.0.0",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Moq": "4.6.38-alpha",
"Newtonsoft.Json": "9.0.1",
@bcnzer
bcnzer / StorageLocation.cs
Created February 13, 2017 19:03
List of storage locations based on isHardcover
public class StorageLocation
{
public bool IsHardcover { get; set; }
public string LocationName { get; set; }
}
// My static storage data, for the purposes of this demo
private readonly List<StorageLocation> _locations = new List<StorageLocation>()
{
new StorageLocation() { IsHardcover = true, LocationName = "General Circulation" },
@bcnzer
bcnzer / BookDetailsController.cs
Created February 13, 2017 19:06
Simple method to get a list of storage locations
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult StorageLocations(bool isHardcover)
{
var locations = _locations.Where(x => x.IsHardcover).ToList();
return Json(locations);
}
<form asp-controller="BookDetails" asp-action="BookDetail" id="bookForm" method="post">
@Html.AntiForgeryToken()
<!-- all my other form controls would be somewhere in here -->
<fieldset>
<label asp-for="IsHardcover" class="label"></label>
<label class="select">
<select asp-for="IsHardcover">
<option value="true">Yes</option>
@bcnzer
bcnzer / MySmallLIbrary.csproj
Created March 23, 2017 17:33
Sample csproj with a version number
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Description>I entered a really nice description. This will show up later in my build</Description>
<Version>1.2.3.4</Version>
</PropertyGroup>
</Project>
@bcnzer
bcnzer / project.json
Created May 1, 2017 06:58
project.json to add StackExchange.Redis for an Azure Function
{
"frameworks": {
"net46":{
"dependencies": {
"StackExchange.Redis": "1.2.1"
}
}
}
}
@bcnzer
bcnzer / timelapse.sh
Last active June 26, 2017 08:31
Create timelapse directory and start timelapse phototaking
mkdir timelapse
cd timelapse
raspistill -o picture%04d.jpeg -tl 10000 -t 7200000