Skip to content

Instantly share code, notes, and snippets.

@peterfleck
peterfleck / docbook-snippets.md
Last active May 14, 2018 15:29
Snippets of Docbook

Docbook Snippets

The Docbook guide can be found here https://tdg.docbook.org/

Paragraphs

Indent paragraphs and allow alignment

  <xsl:attribute-set name="normal.para.spacing">
@peterfleck
peterfleck / README.md
Created February 25, 2019 19:49 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@peterfleck
peterfleck / gitsubmodules.sh
Created October 11, 2019 13:52 — forked from gilbarbara/gitsubmodules.sh
Install git submodules from a .gitmodules file
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
@peterfleck
peterfleck / hmrc.xsl
Created October 21, 2019 13:16
HMRC Currency Exchange Rates
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
<xsl:output method="html" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:variable name="current-year">
<xsl:value-of select="substring(date:year(), 3, 2)" />
</xsl:variable>
<xsl:variable name="current-month">
@peterfleck
peterfleck / express.js
Last active November 16, 2020 11:56
Express Server template
import express from "express";
import hbs from "hbs";
import { join } from "path";
import cookieParser from "cookie-parser";
import cors from "cors";
import helmet from "helmet";
import morgan from "morgan";
import dotenv from "dotenv";
import mongoose from "mongoose";
dotenv.config();
@peterfleck
peterfleck / react-hook-autorefresh.md
Last active November 5, 2020 10:39
React Hook Auto refresh page

export default function Home() {
  const [data, setData] = useState();

  useEffect(() => {
    const interval = setInterval(() => {
      setData((data) => new Date(Date.now()).toLocaleTimeString());
    }, 5000);
 return () =&gt; clearInterval(interval);
@peterfleck
peterfleck / express-install.md
Last active November 6, 2020 17:13
express install

npm install express cookie-parser cors helmet morgan dotenv mongoose joi nodemon uuid

@peterfleck
peterfleck / Express-apply-all.md
Last active December 15, 2020 10:37
Express apply middleware to all

The following callback is executed for requests to /secret whether using GET, POST, PUT, DELETE, or any other HTTP request method:

app.all('/secret', function (req, res, next) {
  console.log('Accessing the secret section ...')
  next() // pass control to the next handler
})

The app.all() method is useful for mapping “global” logic for specific path prefixes or arbitrary matches. For example, if you put the following at the top of all other route definitions, it requires that all routes from that point on require authentication, and automatically load a user. Keep in mind that these callbacks do not have to act as end-points: loadUser can perform a task, then call next() to continue matching subsequent routes.

@peterfleck
peterfleck / deb11.txt
Created January 21, 2022 11:20
Debian 11 (Bullseye) Sources List
# Debian
deb http://deb.debian.org/debian/ bullseye main contrib non-free
deb-src http://deb.debian.org/debian/ bullseye main contrib non-free
deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian/ bullseye-updates main contrib non-free
deb http://security.debian.org/ bullseye-security main contrib non-free
# Node