Skip to content

Instantly share code, notes, and snippets.

View mariusschulz's full-sized avatar
🤓

Marius Schulz mariusschulz

🤓
View GitHub Profile
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@mariusschulz
mariusschulz / lesson-1-global-context.js
Last active December 15, 2023 14:48
Code for my egghead.io course "Understand JavaScript's this Keyword in Depth"
// "use strict";
console.log(this === window);
const square = function(x) {
return x * x;
};
const cube = (x) => {
return x * x * x;
};
const numbers = [11, 20, 33, 40, 55];
@mariusschulz
mariusschulz / list.md
Last active June 25, 2016 13:21
ECMAScript 2015 Resources
@mariusschulz
mariusschulz / deserialization.js
Last active April 19, 2018 14:33
Automatic JSON date deserialization
const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+$/;
function deserializeProperty(key, value) {
return typeof value === "string" && DATE_PATTERN.test(value)
? new Date(value)
: value;
}
const obj = JSON.parse('{ "date": "2016-04-26T18:09:16.61" }', deserializeProperty);
console.log(typeof obj.date);
@mariusschulz
mariusschulz / .eslintrc
Created November 7, 2015 21:39
My ESLint configuration
{
"env": {
"es6": true,
"browser": true,
"node": true
},
"ecmaFeatures": {
"modules": true
},
"rules": {
@mariusschulz
mariusschulz / HtmlHelperExtensions.cs
Last active November 15, 2022 21:54
Two C# extension methods for inlining script and style bundles into the HTML response using ASP.NET MVC and the System.Web.Optimization framework.
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");
@mariusschulz
mariusschulz / Digits.cs
Last active November 4, 2015 16:28
A list of characters that the regular expression pattern \d matches in .NET.
var digitRegex = new Regex(@"\d");
IEnumerable<char> digitCharacters = Enumerable
.Range(1, Char.MaxValue)
.Select(Convert.ToChar)
.Where(c => digitRegex.IsMatch(c.ToString()));
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace IndentedTextWriterDemo
{
public class TodoItem
{
@mariusschulz
mariusschulz / trimStart.js
Created October 11, 2014 16:53
A JavaScript trimStart function
function trimStart(character, string) {
var startIndex = 0;
while (string[startIndex] === character) {
startIndex++;
}
return string.substr(startIndex);
}