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 path = @"R:\test.txt"; | |
const int MAX_LINE_LENGTH = 15; | |
const int MAX_LINE_COUNT = 15; | |
using (var stream = GetTruncatedFile(path, MAX_LINE_LENGTH, MAX_LINE_COUNT)) | |
using (var reader = new StreamReader(stream)) | |
{ |
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() | |
{ | |
foreach (var file in Directory.GetFiles(@"X:\Scott\Projects\Test XML Files", "*.xml")) | |
{ | |
var doc = XDocument.Load(file); | |
var expando = XmlToDict.Convert(doc.Root.Elements(), new LibertyTransformer()); | |
expando.Dump(20); | |
JsonConvert.SerializeObject(expando, Newtonsoft.Json.Formatting.Indented).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
void Main() | |
{ | |
var bytes = new byte[] { 0, 0, 1, 0, 255, 64 }; | |
var reader = new ByteReader(bytes); | |
reader.Read<int>().Dump(); | |
reader.Read<byte>().Dump(); | |
reader.Read<sbyte>().Dump(); | |
reader.Read<byte>(4).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 Benchmark | |
{ | |
/// <summary> | |
/// Returns the total number of milliseconds elapsed running a function [iterations] times. | |
/// </summary> | |
/// <see cref="http://stackoverflow.com/a/1048708/382456" /> | |
public static double Run(int iterations, Action func) | |
{ | |
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; | |
Thread.CurrentThread.Priority = ThreadPriority.Highest; |
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() | |
{ | |
string input = Console.ReadLine(); | |
input.EatHorror("abcdefg"); | |
input.Dump("Eaten"); | |
(input + " - Appended").Dump("Fix?"); | |
"hello".Dump("Try entering \"hello\""); | |
} |
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
/// <summary> | |
/// An in-memory repository of T. | |
/// </summary> | |
/// <typeparam name="T">Type of entities to emulate.</typeparam> | |
public class FakeRepository<T> : IRepository<T> | |
where T : class | |
{ | |
private readonly PropertyInfo _key; | |
private readonly Dictionary<int, T> _entities; |
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
"use strict"; | |
const vm = require("vm"); | |
const util = require("util"); | |
const Constants = require("../constants"); | |
let helpText = `you can evaluate **JS code and expressions** with \`!eval\`! | |
:information_source: Just use \`!eval <code>\`. |
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
// Full function | |
// Returns a value between 0 and 1 representing how often a word appears in a string | |
function wordRate(word, str) { | |
return str.split(word).filter(Boolean).length / str.split(" ").length; | |
} | |
// Golfed/minified, 58 bytes | |
const w = (w,s)=>s.split(w).filter(Boolean).length/s.split` `.length | |
// Usage |
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
// ES3 | |
var getParams = function() { | |
var results = [], parts = window.location.search.slice(1).split("&"), i, len; | |
for (i = 0, len = parts.length; i < len; ++i) results.push(parts[i].split("=")); | |
return results; | |
}; | |
console.log(getParams()); | |
// ES6 | |
const getParams = () => window.location.search.slice(1).split("&").map(q => q.split("=")); |
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
Show hidden characters
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"caret_extra_bottom": 1, | |
"caret_extra_top": 1, | |
"caret_extra_width": 1, | |
"caret_style": "phase", | |
"color_scheme": "Packages/User/SublimeLinter/Oceanic Next (SL).tmTheme", | |
"drag_text": false, | |
"draw_minimap_border": true, |
NewerOlder