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 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 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 ParameterRegex.cs
const string placeholderPattern = @"
\[
\[
([^\]]+) # Description of whatever is in here
\]
\[
([^\]]+) # Description of whatever is in here
\]
\]";
View IndentedTextWriterDemo.cs
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace IndentedTextWriterDemo
{
public class TodoItem
{
@mariusschulz
mariusschulz / Digits.cs
Last active Nov 4, 2015
A list of characters that the regular expression pattern \d matches in .NET.
View Digits.cs
var digitRegex = new Regex(@"\d");
IEnumerable<char> digitCharacters = Enumerable
.Range(1, Char.MaxValue)
.Select(Convert.ToChar)
.Where(c => digitRegex.IsMatch(c.ToString()));
@mariusschulz
mariusschulz / .eslintrc
Created Nov 7, 2015
My ESLint configuration
View .eslintrc
{
"env": {
"es6": true,
"browser": true,
"node": true
},
"ecmaFeatures": {
"modules": true
},
"rules": {
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 / list.md
Last active Jun 25, 2016
ECMAScript 2015 Resources
View arrow-functions.js
const square = function(x) {
return x * x;
};
const cube = (x) => {
return x * x * x;
};
const numbers = [11, 20, 33, 40, 55];
@mariusschulz
mariusschulz / lesson-1-global-context.js
Last active Nov 29, 2017
Code for my egghead.io course "Understand JavaScript's this Keyword in Depth"
View lesson-1-global-context.js
// "use strict";
console.log(this === window);
You can’t perform that action at this time.