Skip to content

Instantly share code, notes, and snippets.

View de1mat's full-sized avatar

Matt Delmarter de1mat

View GitHub Profile
@de1mat
de1mat / grav.chapter.twig
Last active May 17, 2019 23:58
An example Chapter level template for Grav that generates a collection of all child pages, and outputs a menu of the child pages. #grav #twig #template
{% extends 'docs.html.twig' %}
{% block content %}
<div id="chapter">
<div id="body-inner">
<h1>{{ page.title }}</h1>
{{ page.content }}
@de1mat
de1mat / .editorconfig
Last active May 17, 2019 23:56
#github #editor #ide #tabs #conventions #code
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# https://editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
@de1mat
de1mat / grav.toc.twig
Last active May 17, 2019 23:55
A useful Twig template for Grav. Creates a Table of Contents from the headings on the current page (h1, h2, h3...). Requires the Grav `page-toc` plugin. #grav #twig #template
{% if page.content and config.get('plugins.page-toc.active') or attribute(page.header, 'page-toc').active %}
{% set table_of_contents = toc(page.content) %}
{% if table_of_contents is not empty %}
<div class="page-toc">
<h4><i class="fa fa-fw fa-list-alt"></i> Page Outline</h4>
{{ table_of_contents }}
</div>
{% endif %}
{% endif %}
@de1mat
de1mat / shorten.sh
Last active May 18, 2019 21:09
Sometimes when you are working in the terminal you want to hide the current path and increase the visible space for typing commands. Especially if working within a terminal panel in Visual Studio or IntelliJ. #bash #shell
export OLD_PS1=$PS1
export PS1="\u > "export PS1="\u $ "
clear
service:
name: digiStatic
frameworkVersion: ">=1.1.0 <2.0.0"
provider:
name: aws
runtime: nodejs6.10
memorySize: 512
# Serverless variables like ${self:custom.prefix} We use variableSyntax here
@de1mat
de1mat / bottomSheet.js
Created June 11, 2019 00:45 — forked from Topener/index.js
Titanium bottomsheet simple example
var startMove = 0;
var bottomSheet = Ti.UI.createView({
height: 300,
width: Ti.UI.FILL,
backgroundColor: "red",
bottom: -300,
zIndex: 50
});
var overlay = Ti.UI.createView({
void main() {
runApp(_SwitchingThemeApp());
}
/// Properties that help me keep track of the example being run.
bool _useMaterial = false;
class _SwitchingThemeApp extends StatefulWidget {
@override
_SwitchingThemeAppState createState() => _SwitchingThemeAppState();
@de1mat
de1mat / worker.js
Created April 12, 2020 21:32 — forked from tobiaslins/worker.js
Notion Custom Domain using Cloudflare Workers + Splitbee Analytics
const MY_DOMAIN = "help.splitbee.io"
const START_PAGE = "https://www.notion.so/splitbee/Help-Center-bbf26e2b70574901b9c98e5d11e449de"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, HEAD, POST,PUT, OPTIONS",
@de1mat
de1mat / useLocalStorage.js
Created July 22, 2021 20:23
React Hook to persist state to browser localStorage
function useLocalStorage(key, defaultValue) {
const [state, setState] = React.useState(
() => JSON.parse(localStorage.getItem(key)) || defaultValue
);
useEffect(() => {
localStorage.setItem(key, JSON.stringify(state));
}, [key, state]);
return [state, setState];
}

Using JSDOC-Based TypeScript

Get Started

Choose your editor

  • WebStorm, Rider
    • Partial support, not enough intelli hints
    • Toggle on TypeScript language service
  • VSCode