Skip to content

Instantly share code, notes, and snippets.

View HugoDF's full-sized avatar

Hugo HugoDF

View GitHub Profile
@HugoDF
HugoDF / gantt-stripped.md
Last active November 27, 2023 08:50
Stripped Gantt chart to demo sequential request then parallel request
---
config:
    gantt:
        fontSize: 30
        barHeight: 140
---
gantt
    title Demo request then parallel request
 axisFormat %Ss
@HugoDF
HugoDF / config.md
Created July 2, 2020 09:46
Next.js notes

When using a custom Next.js server there are many ways for environment variables to make it into the application:

  • server-side outside of Next (using dotenv)
  • server-side with Next (at build time)
  • server-side with Next (at run time)
  • client-side with Next (at build time)
  • client-side with Next (at run time)

For build time variables:

  • server-side: access using process.env (dotenv or Next will likely pick it up)
@HugoDF
HugoDF / newsletter.md
Created May 17, 2020 15:38
codewithhugo.com newsletter archetype

{{- $date := index (findRE [0-9]{4}-[0-9]{2}-[0-9]{2} .Name 1) 0 -}} {{- $title := replace (replaceRE [0-9]{4}-[0-9]{2}-[0-9]{2}- "" .Name) "-" " " | title -}}

title: {{ $title }} - Code with Hugo - {{ dateFormat "Jan 12th 2006" $date }} publish_date: {{ $date }}

Welcome to the XXXth Edition of the Code with Hugo newsletter about JavaScript, Node.js & Enterprise patterns.

Here are 3 links I think are worth your time this week,

@HugoDF
HugoDF / ABOUT.md
Last active July 6, 2020 01:59
Simple Analytics -> Telegram with Netlify Functions and quickchart.io - used on codewithhugo.com

Getting started

JS dependencies

There's a package.json + lockfile missing, you probably want to use netlify-lambda (npm i --save netlify-lambda) to bundle your code.

Dependencies you need for the code to work:

  • axios - v0.18.x npm i --save axios
  • date-fns - v1.30.x `npm i --save date-fns
@HugoDF
HugoDF / LICENSE.md
Last active October 23, 2023 09:47
Integrate lunrjs with a Hugo (gohugo.io) site.

The MIT License (MIT) Copyright (c) 2019-2020 Hugo Di Francesco

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@HugoDF
HugoDF / newsletter-bookmarks.js
Created April 28, 2019 10:54
Netlify Lambda (has to be build using netlify-lambda library) to fetch pocket entries tagged as "newsletter"
import axios from 'axios'
const {
POCKET_CONSUMER_KEY,
POCKET_ACCESS_TOKEN
} = process.env
async function fetchBookmarks() {
const res = await axios.post('https://getpocket.com/v3/get', {
consumer_key: POCKET_CONSUMER_KEY,
@HugoDF
HugoDF / settings.json
Created February 3, 2019 20:53
Disable autocomplete and IntelliSense in Visual Studio Code, put this in your `.vscode` folder, researched as part of https://codewithhugo.com/async-js
{
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
},
"editor.parameterHints.enabled": false
}
@HugoDF
HugoDF / package.json
Created July 24, 2018 08:24
Express server rendered app with Pug and SCSS
{
"name": "express-pug-scss-starter",
"version": "1.0.0",
"description": "Express server rendered app with Pug and SCSS",
"main": "server.js",
"config": {
"app": "server.js",
"scss": "./src/scss",
"css": "./dist/css",
"img_src": "./src/img/",
@HugoDF
HugoDF / map-snake-to-camel.js
Created June 8, 2018 10:56
Map snake_case to camelCase recursively
const delimiterRegEx = /(_\w)/g;
export function convertSnakeToCamelCase (str) {
return str.replace(delimiterRegEx, ([delimiter, firstChar]) =>
firstChar.toUpperCase()
);
}
export const convertKeysToCamelCase = obj =>
Object.entries(obj).reduce((prev, [key, value]) => {
if (value && typeof value === 'object') {
swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location>