This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Table Formatter | |
// @author DavidG | |
// @grant GM_addStyle | |
// @license MIT | |
// @version 1.1.0.0 | |
// @description Allow copy & paste of tables on Stack Overflow (ALT+V to paste CSV into a table) | |
// @include /^https?:\/\/([\w-]*\.)*((stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com|mathoverflow.net)\/(c\/[^\/]*\/)?(questions|posts|review|tools)\/(?!tagged\/|new\/).*/ | |
// @exclude *://chat.stackoverflow.com/* | |
// @exclude *://chat.stackexchange.com/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Method1((string, string) parameter) | |
{ | |
switch (parameter) | |
{ | |
case var tObj when tObj.Item1 == "x": | |
break; | |
} | |
} | |
//Fails with: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Blah(SomeValue = 4)] | |
public void DoStuff() | |
{ | |
var method = MethodBase.GetCurrentMethod(); | |
var attr = (BlahAttribute)method.GetCustomAttributes(typeof(BlahAttribute), true)[0]; | |
var value = attr.SomeValue; | |
Console.WriteLine(value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult LandscapeControllerlessPdfWithoutLayout() | |
{ | |
var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")); | |
var pdf = generator.GeneratePdf( | |
(writer, document) => | |
{ | |
document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); | |
}, | |
GetModel(), | |
Server.MapPath("~/Views/Pdf/ControllerlessPdfWithoutLayout.cshtml")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JsonExtensions | |
{ | |
public static T Deserialise<T>(this Stream jsonStream) | |
where T : class | |
{ | |
if (jsonStream == null) | |
{ | |
throw new ArgumentNullException(nameof(jsonStream)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var input = "1113222113"; | |
Enumerable.Range(1, 50).ToList().ForEach(i => | |
{ | |
input = Parse(input); | |
}); | |
Console.WriteLine($"{input.Length}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
Part1(); | |
Part2(); | |
} | |
void Part1() | |
{ | |
var lines = File.ReadAllLines(@"C:\Users\David\Documents\LINQPad Queries\input-day8.txt"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var input = File.ReadAllLines(@"C:\Users\David\Documents\LINQPad Queries\input-day2.txt"); | |
var totalPaper = input.Select(i => i.Split('x')).Select(i => i.Select(j => int.Parse(j)).ToList()).Select(i => 2 * i[0] * i[1] + 2 * i[0] * i[2] + 2 * i[1] * i[2] + i.OrderBy(j => j).Take(2).Aggregate((k, l) => k * l)).Sum(); | |
totalPaper.Dump(); | |
var totalRibbon = input.Select(i => i.Split('x')).Select(i => i.Select(j => int.Parse(j)).ToList()).Select(i => i[0]*i[1]*i[2] + i.OrderBy(j => j).Take(2).Aggregate((k, l) => 2*k + 2*l)).Sum(); | |
totalRibbon.Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Logicizer | |
{ | |
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> leftExpression, Expression<Func<T, bool>> rightExpression) | |
{ | |
var parameter = Expression.Parameter(typeof(T)); | |
var left = new ReplaceExpressionVisitor(leftExpression.Parameters[0], parameter) | |
.Visit(leftExpression.Body); | |
var right = new ReplaceExpressionVisitor(rightExpression.Parameters[0], parameter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SE Tab Notifier | |
// @namespace https://gist.github.com/WiredUK | |
// @description Update Tab Title when Inbox has content | |
// @include http://*.stackexchange.com/* | |
// @include http://superuser.com/* | |
// @include http://serverfault.com/* | |
// @include http://meta.stackoverflow.com/* | |
// @include http://stackoverflow.com/* | |
// @include http://stackapps.com/* |
NewerOlder