Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Linnert alinnert

View GitHub Profile
@alinnert
alinnert / CodeMirror.tsx
Last active Jun 28, 2021
CodeMirror 6 React Component
View CodeMirror.tsx
import { FC } from 'react'
import { useCodeMirror } from './useCodeMirror'
interface Props {
content: string
classNames?: string
onContentChange: (content: string) => void
}
export const CodeMirror: FC<Props> = ({
@alinnert
alinnert / levelizeTree.js
Last active Jun 30, 2021
A function that flattens a tree structure while preserving nesting information
View levelizeTree.js
const { map, flatMapDeep, add, flow } = require('lodash/fp')
const data = [
{
id: 1,
type: 'group',
name: 'Colors',
items: [
{ id: 2, type: 'item', name: 'Red' },
{ id: 3, type: 'item', name: 'Purple' },
@alinnert
alinnert / tcmd_menu_deutsch.mnu
Last active Nov 16, 2017
Ein alternatives Menü-File für den Total Commander. Ergebnis einer Aufräumaktion.
View tcmd_menu_deutsch.mnu
POPUP "&Total Commander"
MENUITEM "&Einstellungen...", cm_config
MENUITEM "B&uttonbar anpassen...", cm_ButtonConfig
MENUITEM "Buttonbar &2 (vertikal) anpassen...", 583
MENUITEM "Einstellungs&dateien bearbeiten...", 581
MENUITEM "P&osition speichern", cm_configSavepos
MENUITEM "Einstellungen &speichern", 580
MENUITEM SEPARATOR
POPUP "&Hilfe"
MENUITEM "&Hilfe anzeigen\tF1", cm_HelpIndex
@alinnert
alinnert / classFunctions.js
Last active Nov 16, 2017
ES5 compatible DOM helper functions
View classFunctions.js
/**
* Returns true, if the given element contains the given class. False otherwise.
* @param {Element} element
* @param {String} className
* @returns {boolean}
*/
function hasClass(element, className) {return getClasses(element).indexOf(className) !== -1;}
/**
* Gets all classes of the given element.
@alinnert
alinnert / README.md
Last active Nov 16, 2017
Automatically inserts a TOC to HTML files generated from markdown
View README.md

mdTOC

If inserted in a HTML document auto-generated from markdown a TOC sidebar gets generated automatically.

How to use it with MarkdownPad

MarkdownPad is a Markdown Editor for Windows.

  1. Use the included stylesheet in this Gist. Replace an old one or create a new one.
    • Tools → Options → Stylesheets → Add or Edit
@alinnert
alinnert / README.md
Last active Nov 16, 2017
equalheight.js 1.1.1
View README.md

equalheight.js

This script sets the height of inline-block elements that are displayed in a single line.

It is based on the script from http://css-tricks.com/equal-height-blocks-in-rows/. I added some bug fixes, nice formatting and a version number.

Usage

equalheight(jQuerySelector);