Skip to content

Instantly share code, notes, and snippets.

View jasongaylord's full-sized avatar
⏲️
Trying to find time to code.

Jason N. Gaylord jasongaylord

⏲️
Trying to find time to code.
View GitHub Profile
@jasongaylord
jasongaylord / Cleanup.sql
Created June 28, 2017 17:43
Cleans all objects from a database except the procedure itself
create proc Cleanup
as
declare @n char(1)
set @n = char(10)
declare @stmt nvarchar(max)
-- procedures
@jasongaylord
jasongaylord / PackageVersion.ps1
Created January 25, 2018 16:48
VSTS - Set NuGet Package Version
$pkgver=$(Get-Date -Format 'yyyy.Mdd.Hmmss');
Write-Host "##vso[task.setvariable variable=pkgver]$pkgver"
@jasongaylord
jasongaylord / Default.cshtml
Created November 5, 2018 21:31
Twitter View Component
@model List<TwitterViewComponent.Tweet>
<h3>Recent Tweets</h3>
<ul>
@foreach (var tweet in Model)
{
<li>
@tweet.Message<br/>
<a href="http://twitter.com/@tweet.Username/statuses/@tweet.Id">@(tweet.Timestamp)</a>
</li>
@model List<TwitterViewComponent.Tweet>
<h3>Recent Tweets</h3>
<ul>
@foreach (var tweet in Model)
{
<li>
@tweet.Message<br/>
<a href="http://twitter.com/@tweet.Username/statuses/@tweet.Id">@(tweet.Timestamp)</a>
</li>
{
"TwitterOptions": {
"Username": "jgaylord",
"ConsumerKey": "YOUR_KEY",
"ConsumerSecret": "YOUR_SECRET"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
@await Component.InvokeAsync("RetrieveTweets", new { })
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using TwitterViewComponent;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddTwitter(this IServiceCollection services, IConfiguration configuration = null)
{
public class RetrieveTweetsViewComponent : ViewComponent
{
protected TwitterOptions TwitterOptions { get; private set; }
public RetrieveTweetsViewComponent(IOptions<TwitterOptions> options = null)
{
if (options != null)
TwitterOptions = options.Value;
else
TwitterOptions = new TwitterOptions();
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.1.3" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
public class TwitterOptions
{
[Required]
public string ConsumerKey { get; set; } = "";
[Required]
public string ConsumerSecret { get; set; } = "";
public string Username { get; set; }
}