Skip to content

Instantly share code, notes, and snippets.

🏠
Probably chasing the kids around the house

Scott Sauber scottsauber

View GitHub Profile
View ToDoList.cshtml
@page "/"
<input bind="@SearchTerm" />
<span class="text-muted ml-5">
Showing @FilteredToDos.Count out of @ToDoItems.Count
</span>
<h4 class="mt-4">To Do's</h4>
<ul>
@scottsauber
scottsauber / ToDoList.cshtml
Last active Mar 25, 2019
bind-value-oninput example
View ToDoList.cshtml
@page "/"
<input bind-value-oninput="@SearchTerm" />
<span class="text-muted ml-5">
Showing @FilteredToDos.Count out of @ToDoItems.Count
</span>
<h4 class="mt-4">To Do's</h4>
<ul>
View FileController.cs
[HttpPost("Download/{id:guid}")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Download(Guid id)
{
// Retrieve some file from some service
ApplicationFile file = await _fileService.GetFileAsync(id);
string extension = Path.GetExtension(file.NameWithExtension);
string contentType = "";
View FileController.cs
[HttpPost("Download/{id:guid}")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Download(Guid id)
{
// Retrieve some file from some service
ApplicationFile file = await _fileService.GetFileAsync(id);
var fileProvider = new FileExtensionContentTypeProvider();
// Figures out what the content type should be based on the file name.
if (!fileProvider.TryGetContentType(file.NameWithExtension, out string contentType))
View FileController.cs
[Route("File")]
public class FileController : Controller
{
private readonly IFileService _fileService;
public FileController(IFileService fileService)
{
_fileService = fileService;
}
View FileController.cs
[Route("File")]
public class FileController : Controller
{
[HttpPost("Download/{id:guid}")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Download(Guid id)
{
// Grab a test.pdf back one directory. Look ma - it even runs on Linux with Path.DirectorySeparatorChar!
var fileContent = await File.ReadAllBytesAsync($"..{Path.DirectorySeparatorChar}test.pdf");
View FileController.cs
[Route("File")]
public class FileController : Controller
{
private readonly IFileService _fileService;
public FileController(IFileService fileService)
{
_fileService = fileService;
}
View Program.cs
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Run();
}
public static IWebHost CreateWebHostBuilder(string[] args)
{
var hostBuilder = WebHost.CreateDefaultBuilder(args)
View Something.js
const firstArray = [ 1, 2, 3]; // Prettier will still format this line with its defaults
// prettier-ignore
const secondArray = [
4,
5,
6
];
const somethingElse = 'blah';
View CustomerQueriesWithNameOf.cs
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string ZipCode { get; set; }
}
public List<Customer> GetCustomersByState(string state)
{
var dbConnection = new SqlConnection("SomeConnectionString");
You can’t perform that action at this time.