Skip to content

Instantly share code, notes, and snippets.

View jmreynolds's full-sized avatar

Joe Reynolds jmreynolds

View GitHub Profile
public class KeysJsonConverter : JsonConverter
{
private readonly Type[] _types;
public KeysJsonConverter(params Type[] types)
{
_types = types;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public static void GetAttribute(Type t)
{
DeveloperAttribute att;
// Get the class-level attributes.
// Put the instance of the attribute on the class level in the att object.
att = (DeveloperAttribute) Attribute.GetCustomAttribute (t, typeof (DeveloperAttribute));
if (att == null)
@jmreynolds
jmreynolds / BadAlias.sql
Last active April 22, 2016 20:59
Gist with samples for my SSMS and LinqPad blog post
SELECT [t1].[column] FROM [MyTable] AS [t1]
@jmreynolds
jmreynolds / cleanVisualStudioBuildFiles.ps1
Created March 5, 2016 19:25
Super Useful trick to include in build scripts as a "pre-build" step. Makes sure you always start fresh. From https://sachabarbs.wordpress.com/2014/10/24/powershell-to-clean-visual-studio-binobj-folders/
gci -inc bin,obj -rec | rm -rec -force
@jmreynolds
jmreynolds / DumpToExcel.cs
Created March 4, 2016 03:28 — forked from bryanhunter/DumpToExcel.cs
Painless way to build Microsoft Excel spreadsheets from any IEnumerable<T>. Does not require Excel.
using System.Collections.Generic;
using System.IO;
using OfficeOpenXml; // (EPPLus - http://epplus.codeplex.com/)
namespace OfficeReports
{
public static class DumpToExcel
{
public static void Dump<T>(IEnumerable<T> data, string outputFilename)
{
@jmreynolds
jmreynolds / SearchString.ps1
Last active March 4, 2016 00:28
I'm forever needing to search through files for various strings and either pipe them to the command line or send them to a file. Here's a couple commands to help out. From http://stackoverflow.com/questions/8153750/how-to-search-a-string-in-multiple-files-and-return-the-names-of-files-in-powers
#push direct to the command line.
Get-ChildItem -recurse | Select-String -pattern "dummy" | group path | select name
# a little more setup, but pushes out to a txt file
# Nice for searching for specific errors in a bunch of log files.
$logdir = "SOMEDIR"
$csvpath = "SOMEPATH"
gci $logdir -rec *.txt | gc | select-string $pattern | add-content $csvpath
@jmreynolds
jmreynolds / console.xml
Last active February 26, 2016 17:36
My Console2 \ ConsoleZ settings. Note, I typically install KickAss console from Chocolatey - a collection of tools curated by @alanstevens. I'm experimenting with ConEmu - but I've used console2 for so long I don't see switching.
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="25" columns="80" buffer_rows="500" buffer_columns="0" shell="" init_dir="" start_hidden="0" save_size="0">
<colors background_text_opacity="255">
<!-- ir_black -->
<color id="0" r="0" g="0" b="0"/>
<color id="1" r="150" g="203" b="254"/>
<color id="2" r="168" g="255" b="96"/>
<color id="3" r="198" g="197" b="254"/>
<color id="4" r="255" g="108" b="96"/>
@jmreynolds
jmreynolds / GetDatabaseInfo.linq.cs
Created February 23, 2016 00:13 — forked from jamesmanning/GetDatabaseInfo.linq.cs
LINQPad script to get basic schema information about the currently selected database (assumes LINQPad's default data context creation method)
void Main()
{
var databaseInfo = GetDatabaseInfo(this);
databaseInfo.Dump();
}
// Define other methods and classes here
public class DatabaseInfo
{
public Type DataContextType { get; set; }
<!-- Useful for styles with static names... -->
<link href="{{ site.github.url }}/path/to/css.css" rel="stylesheet">
<!-- and for documents/pages whose URL's can change... -->
<a href="{{ page.url | prepend: site.github.url }}">{{ page.title }}</a>
@jmreynolds
jmreynolds / futurepostinfo.html
Created February 19, 2016 20:09
Should let me display info about upcoming posts in jekyll From http://stackoverflow.com/questions/24353638/show-only-future-posts-in-jekyll
{% assign curDate = site.time | date: '%s' %}
{% for post in site.posts %}
{% assign postStartDate = post.date | date: '%s' %}
{% if postStartDate >= curDate %}
Post datas here
{% endif %}
{% endfor %}