This file contains hidden or 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 pre = SOURCE.Substring(0, SOURCE.LastIndexOf(DELIMITER)); | |
string post = SOURCE.Substring(SOURCE.LastIndexOf(DELIMITER) + 1); | |
Console.Write(pre + SOURCE.Replace("\"", "\"\"") + post); | |
} | |
// Define other methods and classes here | |
const char DELIMITER = '$'; | |
const string SOURCE = @"void Main() |
This file contains hidden or 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() | |
{ | |
ParamNames.TESTVALUE.Dump(); | |
ParamNames.TEST.Dump(); | |
ParamNames p1 = ((ParamNames)ParamNames.TESTVALUE).Dump(); | |
//Not possible: | |
//ParamNames p2 = (ParamNames.TESTVALUE as ParamNames); | |
bool t3 = (p1 == ParamNames.TEST).Dump(); | |
bool t4 = (p1 == (ParamNames)ParamNames.TESTVALUE).Dump(); | |
bool t5 = (p1 == ParamNames.TESTVALUE).Dump(); |
This file contains hidden or 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() | |
{ | |
_filters.Add("Integer", new FilterItem<int>(999)); | |
_filters.Add("IntegerList", new FilterListItem<int>(new [] { 1, 2, 3, 863, 2452, 24 })); | |
_filters.Add("string", new FilterItem<string>("test str")); | |
foreach (var kvp in _filters) | |
{ | |
kvp.Value.GetQueryString().Dump(); | |
} |
This file contains hidden or 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() | |
{ | |
Guid UserGuid = new Guid("99a2caf0-0c9b-4452-9313-ff6a1d9786fa"); | |
using (MemoryStream ms = new MemoryStream()) | |
using (Stream cs = BasicGoodEncrypt(UserGuid, "imalittleteapot", ms)) | |
{ | |
} | |
} |
This file contains hidden or 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
Playing with HSL colors in javascript | |
http://jsfiddle.net/HfCw2/ |
This file contains hidden or 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
var _ = require("underscore"); | |
function AppleStoreProduct(baseData) { | |
_.extend(this, baseData); | |
} | |
var specsLookup = [ | |
//Very specific ones... only single matches | |
{ match: /^(Refurbished |)(?:([0-9\.]+-inch) )?(MacBook (?:Air|Pro)) ([0-9\.]+ ?GHz) ([dD]ual-core|Quad-core) (Intel (?:Core )?(i5|i7))( with Retina Display|)$/, |
This file contains hidden or 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> | |
/// How to use this: | |
/// 1. Get the reference | |
/// a. Inject IDebugTimerRepository | |
/// b. call DebugTimerRepository.Instance | |
/// 2. Log values | |
/// a. Call _debugTimerRepository.AddValue(string label, long value) | |
/// Probably using value == Stopwatch.TotalMiliseconds | |
/// | |
/// Option 2: |
This file contains hidden or 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() | |
{ | |
//Usage is simply, anywhere in the solution: | |
CodeCalledRepository.Instance.CodeHit(CodeCalled.OldAssEmail1); | |
//Result is: | |
Database.Dump("Result 1"); | |
CodeCalledRepository.Instance.DEBUGDUMP(); | |
This file contains hidden or 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> | |
///Saw a thing about Currying in javascript frameworks, thought I'd throw the ability to do similar in C# | |
/// (Somewhere in this https://news.ycombinator.com/item?id=8652348) | |
///</summary> | |
public static class CurryExtensions | |
{ | |
//Supplying 1 value | |
public static Func<T2, TOut> Curry<T1, T2, TOut>(this Func<T1, T2, TOut> func, T1 value) | |
{ | |
return x => func(value, x); |
This file contains hidden or 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
:: Check if argument equals string | |
if /i "%1" equ "/resume" ( | |
echo Resuming now! | |
) | |
:: Allow argument, but override if needed | |
set action=%1 | |
if "%action%"=="" ( | |
set action=start | |
) |
OlderNewer