Skip to content

Instantly share code, notes, and snippets.

View miclgael's full-sized avatar
🐱
Looking at pictures of my cats

Michael Gale (he/him) miclgael

🐱
Looking at pictures of my cats
View GitHub Profile
@ayoayco
ayoayco / gh-alerts.md
Created December 14, 2023 12:16
GH Alerts in MD files

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

[!WARNING]

@tigt
tigt / git-branch-to-favicon.js
Created March 18, 2020 21:10
Creates an SVG string that can be used as a favicon across different Git branches. Actually getting this into the browser is sadly project-specific.
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
const hash = createHash('sha256')
hash.update(branchName)
const color = '#' + hash.digest().toString('hex').substring(0, 6)
const invertedColor = invertColor(color, true)
@jotazzu
jotazzu / edit-screen.php
Last active December 19, 2019 23:59
Replaces deprecated calls to create_function() in WordPress plugin Tabify Edit Screen with anonymous function definitions. See https://wordpress.org/support/topic/another-patch-create_function-is-deprecated-since-php-7-2/
<?php
/**
* //JT 13.12.19: create_function() is deprecated.
*/
include 'tabs.php';
class Tabify_Edit_Screen_Edit_Screen {
@Sacristan
Sacristan / push_commits_by_chunks.sh
Last active May 22, 2025 03:51
Push commits by chunks
REMOTE=origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BATCH_SIZE=10
# check if the branch exists on the remote
# if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then
# # if so, only push the commits that are not on the remote already
# range=$REMOTE/$BRANCH..HEAD
# else
# # else push all the commits
function squarify (children, row, width) {
if (children.length === 1) {
layoutLastRow(row, children, width)
return
}
const rowWithChild = [...row, children[0]]
if (row.length === 0 || worst(row, width) >= worst(rowWithChild, width)) {
@clementbat
clementbat / treemap-algorithm
Created February 26, 2019 11:13
treemap algorithm
procedure squarify(list of real children, list of real row,real w)
begin
real c = head(children);
if worst(row, w) ≤ worst(row++[c], w) then
squarify(tail(children), row++[c], w)
else
layoutrow(row);
squarify(children, [], width());
fi
end
@ayoayco
ayoayco / update-commits
Created October 19, 2018 03:46
update author info in git commits
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Ayo"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@benjamineskola
benjamineskola / evening.applescript
Last active November 30, 2022 09:57
Automatically set repeating tasks tagged ‘Evening’ to be done this evening, in Things 3 — updated versions here: https://github.com/benjamineskola/things-scripts/blob/master/evening.applescript
-- run first thing in the morning, e.g., from cron
tell application "Things3"
set theToken to "your-auth-token"
set theTodos to to dos of list "Today"
repeat with aTodo in theTodos
set tagList to tags of aTodo
repeat with aTag in tagList
if (name of aTag as text) is "Evening"
@kizzx2
kizzx2 / docker-compose.yml
Last active June 18, 2025 19:17
Restart a docker container periodically with docker-compose
version: '3'
services:
app:
image: nginx:alpine
ports: ["80:80"]
restart: unless-stopped
restarter:
image: docker:cli
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
@styblope
styblope / docker-api-port.md
Last active June 29, 2025 01:32
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}