Skip to content

Instantly share code, notes, and snippets.

View patricknelson's full-sized avatar
:shipit:
Pushing 1's and 0's.

Patrick Nelson patricknelson

:shipit:
Pushing 1's and 0's.
View GitHub Profile
@NightJar
NightJar / Site IA review query.sql
Created February 27, 2023 02:53
An SQL query that will get a list of every page on the site (regardless of visibility to any given user) along with published status. Useful for information architecture (IA) reviews by site owners or groups thereof.
-- file names are relative to the active database's data directory (e.g. /var/lib/mysql/SS_yoursite/${outfile}.csv) and are therefore only readable by the mysql user (use sudo) - or output to an absolute path with write permission e.g. /tmp as below
with recursive kids as (
select st.ID, URLSegment, cast(URLSegment as varchar(1000)) as Link, ParentID, Title, st.Version, LastEdited
from SiteTree st
left join Page pagedata on st.ID = pagedata.ID
where st.ParentID = 0
union all
select child.ID, child.URLSegment, cast(concat(parent.Link, '/', child.URLSegment) as varchar(1000)) as Link, child.ParentID, child.Title, child.Version, child.LastEdited
from SiteTree as child
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>🔥 Make a photo booth app in about 15 lines of JavaScript</title>
<link rel="icon" href="https://fav.farm/🎥" />
</head>
<body>
@bubba-h57
bubba-h57 / instructions.md
Last active May 16, 2026 13:09
Configuring Jetbrains Gateway and WSL

Step 1: SSH Daemon

In your WSL instance, re-install OpenSSH server as follows.

sudo apt remove --purge openssh-server
sudo apt install openssh-server

Edit /etc/ssh/sshd_config (e.g. sudo vi /etc/ssh/sshd_config) and add the following lines to the bottom of the file. Ensure you replace WSL_ACCOUNT_NAME with your WSL2 account name.

@AdamManuel-dev
AdamManuel-dev / Svelte Custom Element v1 Wrapper
Last active April 28, 2023 21:35
This is a wrapper for turning a Svelte Component built as an entry point into a Web Component using the Custom Element v1 Spec
import Gallery from './COA/COAGallery.svelte';
/**
* C.O.A. Gallery Custom Element v1 Component Class
*/
class COAGallery extends HTMLElement {
/**
* This defines the attributes to watch in the custom element to trigger the `attributeChangedCallback` method
*/
static get observedAttributes() {
<?php
namespace Nightjar\SS4UpgradeTasks;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use SilverStripe\Assets\File;
use SilverStripe\Control\Director;
use SilverStripe\Core\ClassInfo;
@danieldogeanu
danieldogeanu / RenameGitBranch.md
Last active February 2, 2026 05:53
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main

@Ragnoroct
Ragnoroct / __fastgit_ps1.sh
Created February 26, 2020 19:45
Blazing fast simple git branch name for ps1
# Copyright (c) 2019 Will Bender. All rights reserved.
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
# Very fast __git_ps1 implementation
# Inspired by https://gist.github.com/wolever/6525437
# Mainly this is useful for Windows users stuck on msys, cygwin, or slower wsl 1.0 because git/fs operations are just slower
# Caching can be added by using export but PROMPT_COMMAND is necessary since $() is a subshell and cannot modify parent state.
# Linux: time __ps1_ps1 (~7ms)
@maxkostinevich
maxkostinevich / index.html
Last active June 28, 2025 15:51
Cloudflare Worker - Handle Contact Form
<!--
/*
* Serverless contact form handler for Cloudflare Workers.
* Emails are sent via Mailgun.
*
* Learn more at https://maxkostinevich.com/blog/serverless-contact-form
* Live demo: https://codesandbox.io/s/serverless-contact-form-example-x0neb
*
* (c) Max Kostinevich / https://maxkostinevich.com
*/
@fffonion
fffonion / setup-dashbutton.py
Created September 28, 2019 22:32
Setting up dash button without Amazon App
import requests
import re
import sys
# Initial work from: https://mpetroff.net/2016/07/new-amazon-dash-button-teardown-jk29lp/
h = requests.Session()
BASE_URL = "http://192.168.0.1"
@liamfiddler
liamfiddler / style.11ty.js
Last active August 29, 2023 23:04
SCSS + PostCSS pipeline for 11ty
// sass dependencies: `npm i -D sass`
const util = require('util');
const sass = require('sass');
const renderSass = util.promisify(sass.render);
// postcss dependencies: `npm i -D autoprefixer postcss precss`
const autoprefixer = require('autoprefixer');
const postcss = require('postcss');
const precss = require('precss');
const postcssProcessor = postcss([precss, autoprefixer]);