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
using System; | |
using System.IO; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Web.Mvc; | |
namespace DemoApp | |
{ | |
public class ExternalJavaScriptFileAttribute : ActionFilterAttribute | |
{ |
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
public string DecryptQueryString(string inputText, string key, string salt) | |
{ | |
byte[] encryptedData = Convert.FromBase64String(inputText); | |
var secretKey = new PasswordDeriveBytes(Encoding.ASCII.GetBytes(key), Encoding.ASCII.GetBytes(salt)); | |
using (var rijndaelCipher = new RijndaelManaged()) | |
using (var decryptor = rijndaelCipher.CreateDecryptor(secretKey.GetBytes(32), secretKey.GetBytes(16))) | |
using (var memoryStream = new MemoryStream(encryptedData)) | |
using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) | |
{ |
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
private static bool BinarySearch(int[] sortedHaystack, int needle) | |
{ | |
int leftBoundary = 0; | |
int rightBoundary = sortedHaystack.Length - 1; | |
while (leftBoundary <= rightBoundary) | |
{ | |
int pivotIndex = (int)(((long)leftBoundary + rightBoundary) / 2); | |
int pivotValue = sortedHaystack[pivotIndex]; |
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
isPrime = (n) -> | |
return true if n is 2 or n is 3 | |
return false if n % 2 is 0 | |
for i in [3..Math.sqrt n] | |
return false if n % i is 0 | |
true | |
primesUnder100 = (n for n in [1..100] when isPrime n) |
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
const string placeholderPattern = @" | |
\[ | |
\[ | |
([^\]]+) # Description of whatever is in here | |
\] | |
\[ | |
([^\]]+) # Description of whatever is in here | |
\] | |
\]"; |
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
function trimStart(character, string) { | |
var startIndex = 0; | |
while (string[startIndex] === character) { | |
startIndex++; | |
} | |
return string.substr(startIndex); | |
} |
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
using System; | |
using System.CodeDom.Compiler; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
namespace IndentedTextWriterDemo | |
{ | |
public class TodoItem | |
{ |
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 digitRegex = new Regex(@"\d"); | |
IEnumerable<char> digitCharacters = Enumerable | |
.Range(1, Char.MaxValue) | |
.Select(Convert.ToChar) | |
.Where(c => digitRegex.IsMatch(c.ToString())); |
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
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Optimization; | |
public static class HtmlHelperExtensions | |
{ | |
public static IHtmlString InlineScripts(this HtmlHelper htmlHelper, string bundleVirtualPath) | |
{ | |
return htmlHelper.InlineBundle(bundleVirtualPath, htmlTagName: "script"); |
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
{ | |
"env": { | |
"es6": true, | |
"browser": true, | |
"node": true | |
}, | |
"ecmaFeatures": { | |
"modules": true | |
}, | |
"rules": { |
OlderNewer