Skip to content

Instantly share code, notes, and snippets.

View TerribleDev's full-sized avatar
🦄
Love Coffee

Tommy Parnell TerribleDev

🦄
Love Coffee
View GitHub Profile
@TerribleDev
TerribleDev / DataBase.cs
Last active August 29, 2015 14:03
DataAccess with Generics
public class DataBase<T> where T : class, IDbConnection, new()
{
//connection string
private string ConnectionString { get; set; }
//connection string in constructor
public DatabaseBase(string connectionstring)
{
//if its null or empty throw error
if (string.IsNullOrWhiteSpace(connectionstring)) throw new ArgumentNullException("connectionstring");
ConnectionString = connectionstring;
@TerribleDev
TerribleDev / Primer.cs
Last active August 29, 2015 14:27
Jit your application (run at startup)
using System;
using System.Reflection;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
namespace MyApp.AppStart
{
public static class Primer
{
public partial class Service1 : ServiceBase
{
private Timer timer = new Timer(300000);
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
@TerribleDev
TerribleDev / Infinate.cs
Last active November 5, 2015 23:59
Get Friday the 13ths Linq Style
void Main()
{
var next5Friday13 = DateTime.Today
.Recurse(a=>a.AddDays(1))
.Where(a=>a.Day == 13 && a.DayOfWeek == DayOfWeek.Friday).Take(5);
}
public static class Extension
{
public static IEnumerable<T> Recurse<T>(this T obj, Func<T,T> action)
@TerribleDev
TerribleDev / web.config
Created November 28, 2015 15:17
Backward compat hexo's rss feed for hexo in IIS/azure
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SpecificRewrite" stopProcessing="true">
<match url="^rss$" />
<action type="Rewrite" url="public/rss.xml" />
</rule>
</rules>
</system.webServer>
@TerribleDev
TerribleDev / UploadS3.cs
Last active January 19, 2016 12:33
uploading to S3
public async Task UploadArtifact(S3Config config, IAmazonS3 s3Client)
{
using(var utility = new TransferUtility(s3Client))
{
Console.WriteLine($"Uploading artifact {config.ArtifactRelativePath} {config.Key}");
await utility.UploadAsync(filePath: config.ArtifactRelativePath, bucketName: config.S3Bucket, key: config.Key);
}
}
@TerribleDev
TerribleDev / setup.sh
Last active February 25, 2016 12:29
install vagrant-orchestrate
#!/bin/bash
sudo apt-get update -y
sudo apt-get install git aptitude puppet -y
sudo aptitude install ruby2.0 -y
wget https://releases.hashicorp.com/vagrant/1.7.4/vagrant_1.7.4_x86_64.deb
dpkg --install vagrant_1.7.4_x86_64.deb
vagrant plugin install vagrant-managed-servers --plugin-version 0.6.0
vagrant plugin install vagrant-orchestrate
gem install librarian-puppet
@TerribleDev
TerribleDev / intolerance.cs
Last active March 29, 2016 00:41
Query Allergy intolerance
using Hl7.Fhir.Model;
internal class Program
{
private static void Main(string[] args)
{
var client = new Hl7.Fhir.Rest.FhirClient("http://52.72.172.54:8080/fhir/baseDstu2/");
var result = client.Read<Patient>("Patient/Patient-19454");
var allergyResult = client.Read<AllergyIntolerance>("AllergyIntolerance/AllergyIntolerance-19454");
}
}
public class main
{
public string awesome {get;set;}
public string dawg {get {return "yo dawg"}}
public string coolio {get; private set;}
public string customSet {get; set{this = value}}
}
public class student{
public string FirstName {get;set;}
public string LastName {get;set;}
@TerribleDev
TerribleDev / rewrite.cs
Last active April 2, 2016 23:14
rewrite
private IEnumerable<string> DetermineListOfAllergicMedications(List<string> medications, Dictionary<string, bool> lookupPatientsKnownAllergies)
{
return
medications
.Where(a => allergyLookup.ContainsKey(a))
.Select(a => new Tuple<string, List<string>>(a, allergyLookup[a]))
.Where(a => a.Item2.Any(c => lookupPatientsKnownAllergies.ContainsKey(c)))
.Select(a => a.Item1);
}