Skip to content

Instantly share code, notes, and snippets.

Marius Schulz mariusschulz

Block or report user

Report or block mariusschulz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ParameterRegex.cs
const string placeholderPattern = @"
\[
\[
([^\]]+) # Description of whatever is in here
\]
\[
([^\]]+) # Description of whatever is in here
\]
\]";
View isPrime.coffee
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)
View BinarySearch.cs
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];
View gist:6594870
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))
{
@mariusschulz
mariusschulz / ExternalJavaScriptFileAttribute.cs
Last active Dec 28, 2017
Here's the ExternalJavaScriptFileAttribute that I showed in my blog post "Generating External JavaScript Files Using Partial Razor Views" (see http://blog.mariusschulz.com/generating-external-javascript-files-using-partial-razor-views).
View ExternalJavaScriptFileAttribute.cs
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Mvc;
namespace DemoApp
{
public class ExternalJavaScriptFileAttribute : ActionFilterAttribute
{
You can’t perform that action at this time.