Skip to content

Instantly share code, notes, and snippets.

View RickCogley's full-sized avatar
👻
Slowly but surely implementing ISO 27001 ISMS

Rick Cogley RickCogley

👻
Slowly but surely implementing ISO 27001 ISMS
View GitHub Profile
@RickCogley
RickCogley / standard-english-hyphenation.css
Last active November 14, 2024 04:02
English Hyphenation
/* Language supports hyphenation ハイフン対応可能な言語 */
html[lang="en"] {
text-align: left;
-webkit-hyphens: auto;
-webkit-hyphenate-limit-before: 3;
-webkit-hyphenate-limit-after: 3;
-webkit-hyphenate-limit-chars: 6 3 3;
-webkit-hyphenate-limit-lines: 2;
-webkit-hyphenate-limit-last: always;
-webkit-hyphenate-limit-zone: 8%;
@RickCogley
RickCogley / Correct_GnuPG_Permission.sh
Created November 4, 2024 08:39 — forked from oseme-techguy/Correct_GnuPG_Permission.sh
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@RickCogley
RickCogley / 1 CMS git.md
Last active November 3, 2024 23:14
Tips for git with cms

I have a situation where I have scripts pushing changes to a github repository on feature branches. What settings should I use to make the process as smooth as possible?

To ensure a smooth process for scripts pushing changes to a GitHub repository on feature branches, consider the following settings and best practices:

  1. Branch Protection Rules:

    • Enable branch protection rules to prevent direct pushes to the main branch. This ensures that all changes go through a pull request (PR) process.
    • Require status checks to pass before merging. This can include automated tests or other CI/CD checks.
  2. Commit Messages:

@RickCogley
RickCogley / readme.md
Last active January 6, 2024 00:36
Markdown 基礎の基礎

Markdown とは、元々John Gruber氏のこちらのブログで仕様説明が発表されてから色んなシステムが使っています。

検索すれば様々な情報が出ますが、基礎の基礎として:

テキストにボルド体にするには:

**ボルド体**

日本語では珍しいかもしれないけど イタリック体 もあり:

@RickCogley
RickCogley / 1. Readme.md
Last active May 14, 2023 01:17
Append to Dictionary File in nushell

Appending Words to a Dictionary File in Nushell

I call a dictionary file from my nupass.nu password generator command, which is simply a file with one Japanese word or phrase per line. I wanted to be able to easily add words to the dictionary file, followed by a quick git commit, hence this nushell script.

In this case, it's easy to just add those commands to nushell's env.nu instead of having them as a separate script file. Once added, I just reloaded nushell, and then it was just a matter of doing the following to add the words to the file:

> dict add onepiece golgo13 dragonball naruto doraemon 

See the screenshot below for what the output looks like.

@RickCogley
RickCogley / 1. Readme.md
Last active May 3, 2023 00:05
Nushell password generator

Nushell Password Generator "nupass"

This nushell command randomly retrieves a specified number of words from a dictionary file (English with Japanese words added by @rickcogley) less than or equal to a given parameter's length, formats the words randomly with capitalization, then separates the words with some random symbols and numbers to return a password.

To use:

  1. Get the dictionary file to your system using nushell's http:
http get https://raw.githubusercontent.com/RickCogley/jpassgen/master/genpass-dict-jp.txt | save genpass-dict-jp
@RickCogley
RickCogley / 1. Readme.md
Last active October 15, 2024 20:11
Use HTMX to Access DBFlex / Teamdesk REST API JSON data

Use HTMX to Access DBFlex / Teamdesk REST API JSON data

You can access the DBFlex / Teamdesk REST API using HTMX, specifically its "client side templates" extension. Use the API Playground from setup to get the URL to target with hx-get.

DBFlex wraps its json in an array, so if you're using a Mustache template, you need to wrap the field you're accessing like this:

{{#.}} {{ Holiday Name }} {{/.}}
:where(html) {
--gray-0-hsl: hsl(210, 17%, 98%);
--gray-1-hsl: hsl(210, 17%, 95%);
--gray-2-hsl: hsl(210, 16%, 93%);
--gray-3-hsl: hsl(210, 14%, 89%);
--gray-4-hsl: hsl(210, 14%, 83%);
--gray-5-hsl: hsl(210, 11%, 71%);
--gray-6-hsl: hsl(210, 7%, 56%);
--gray-7-hsl: hsl(210, 9%, 31%);
--gray-8-hsl: hsl(210, 10%, 23%);
@RickCogley
RickCogley / 1. Readme.md
Last active May 28, 2023 23:36
Deploy Hugo to Deno Deploy via Github Actions

Background

Deno Deploy is an excellent, performant and cost-effective service geared toward hosting Deno apps at the edge. It can easily host a folder of static HTML files, if you provide an index.ts to launch something like "oak" to serve them (example index.ts below).

(It's important to note that it's still officially considered beta as of May 2023, and there have been some surprising periods of downtime over the past few months... just be sure to keep that in mind)

Hugo is a phenomenally fast-building and mature SSG, which can produce a folder of static files, but requires a build step like hugo --gc --minify --verbose --baseURL=$HUGOBASEURL --ignoreCache to generate them.

Below is a yaml file you would place in your project's .github/workflows folder. If you link your Deno Deploy project using Github Actions instead of specifying an index file, it will defer to what's in this. In this case, the Hugo files generated into public are being serv

@RickCogley
RickCogley / 1. Readme.md
Last active November 8, 2024 20:38
Standard Security Headers

This set of "low-hanging fruit" security headers can be set for most websites to cover a range or potential problems and get a better ranking on https://securityheaders.com/. You should not that this does not cover CORS/CSP headers, because they are not "one size fits all" and require trial and error to set. Among these standard headers, the "Permissions-Policy" (previously "Feature-Policy") header requires a bit of thought, and trial and error, so be sure to review and edit as appropriate.

Generally speaking, although you can set some of these directly in HTML, you usually set security headers on the server side, for example in a .htaccess file on Apache, in a file like vercel.json in the root of your site if you're hosting on Vercel (similar for Netlify and can be done in their config file, see below), or under "web rules, header rules" UI if you're hosting on WP Engine (see screenshot).

It's also super simple to implement a static HTML site deployed on Deno Deploy, and served via Deno Oak. See th