Skip to content

Instantly share code, notes, and snippets.

View endiliey's full-sized avatar

Endi endiliey

View GitHub Profile
@endiliey
endiliey / test.md
Created November 20, 2019 16:41
remark-slug test

Foo

Foo

@endiliey
endiliey / a.md
Last active November 20, 2019 16:13

Hello. // (world?)!

Über Café.

@endiliey
endiliey / benchmark.js
Last active November 11, 2019 16:43
Get the frontmatter and first non empty line content from a file
const Benchmark = require("benchmark");
const fm = require("front-matter");
const fs = require("fs-extra");
const glob = require("glob");
const path = require("path");
const readlinestream = require("./stream");
const matter = require("gray-matter");
async function grayMatter(fixtures) {
import matter from 'gray-matter';
import {createHash} from 'crypto';
import _ from 'lodash';
import escapeStringRegexp from 'escape-string-regexp';
import fs from 'fs-extra';
import readline from 'readline';
import {once} from 'events';
function isSeparator(line: string) {
export default function(babel) {
const { types: t } = babel;
return {
name: "ast-transform", // not required
visitor: {
ObjectExpression(path) {
var source = path.node.source.value;
if (source !== '@generated/registry') return;
export function getIePolyfill(siteDir: string) {
let iePolyfill = '';
const env =
process.env.NODE_ENV === 'production' ? 'production' : 'development';
const supportedBrowsers = browserslist(undefined, {path: siteDir, env});
if (
supportedBrowsers.includes('ie 9') ||
supportedBrowsers.includes('ie 10')
) {
@endiliey
endiliey / react-live.md
Created June 4, 2019 08:24
react live testing
function Clock(props) {
  const [date, setDate] = useState(new Date());
  useEffect(() => {
    var timerID = setInterval(() => tick(), 1000);

    return function cleanup() {
      clearInterval(timerID);
    };
 });
@endiliey
endiliey / filename.benchmark.js
Created May 19, 2019 08:51
benchmark path.basename(file, path.extname(file)) vs path.parse(file).name
const path = require('path');
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
const files = [
'C:\\temp\\myfile.html',
'a.md',
'hello/super.js',
'test.ts',
'superman/hello/haha.md',
@endiliey
endiliey / generate.js
Last active May 17, 2019 11:54
Simple node script to generate random GitHub flavored valid markdown
const globby = require("globby");
const fs = require("fs-extra");
const path = require("path");
const fetch = require("node-fetch");
function randomName(length) {
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
@endiliey
endiliey / InlineManifestHtmlWebpackPlugin.js
Created April 18, 2019 17:07
InlineManifestHtmlWebpackPlugin
const fs = require('fs');
const path = require(`path`);
class InlineManifestHtmlWebpackPlugin {
constructor(options) {
this.options = Object.assign(
{manifestFileName: 'chunk-map.json', manifestVariable: '__chunkMapping'},
options,
);
}