Skip to content

Instantly share code, notes, and snippets.

View allain's full-sized avatar

Allain Lalonde allain

View GitHub Profile
@allain
allain / clone-all-gitlab.sh
Created December 18, 2025 15:13
Clone all accessible gitlab repos
#!/bin/bash
# --- Configuration ---
# GITLAB_URL and GITLAB_TOKEN must be set as environment variables
if [ -z "$GITLAB_URL" ]; then
echo "ERROR: GITLAB_URL environment variable is not set"
exit 1
fi
if [ -z "$GITLAB_TOKEN" ]; then
@allain
allain / clone-all-github.sh
Last active December 18, 2025 15:11
Clone all Github Repos
#!/bin/bash
# Usage
# USERNAME=username ./clone-all-github.sh
# Ensure gh CLI is installed
if ! command -v gh &> /dev/null; then
echo "gh CLI not found."
exit 1
fi
@allain
allain / find-uncommited.sh
Last active December 17, 2025 14:15
Find Repose with uncommited changes recursively
#!/bin/bash
# Find all git repositories recursively and print those with uncommitted changes
# Find all .git directories
find . -type d -name ".git" 2>/dev/null | while read -r git_dir; do
# Get the repository root (parent of .git directory)
repo_path=$(dirname "$git_dir")
# Convert to absolute path
@allain
allain / PromisedValue.mjs
Created February 18, 2022 23:30
Use Promises without unboxing them
// Usage:
// console.log(await new PromisedValue([1,2,3]).map(x => x * 2).filter(x => x % 2))
//
// instead of this:
// console.log(await Promised.resolve([1,2,3])
// .then(arr => arr.map(x => x * 2))
// .then(arr => arr.filter(x => x % 2)))
export function PromisedValue(target) {
target = Promise.resolve(target)
@allain
allain / x-component.mjs
Last active July 28, 2023 09:57
x-component alpine.js directive for defining web components
export default function (Alpine) {
const findInParent = (prop) => (el) => {
while (el && !el[prop]) el = el.parentElement
return el?.[prop]
}
Alpine.magic('attrs', findInParent('_x_attrs'))
Alpine.magic('props', findInParent('_x_props'))
Alpine.magic('slots', findInParent('_x_slots'))
Alpine.directive('component', xComponentDirective)
@allain
allain / items.spec
Last active August 8, 2020 16:42
Dream Code for a Event Sourced DSL System
context items
// Define commands and their respective events when they succeed.
// creatorId would be extracted from the context of the command
command CreateItem {
title: String!
} -> ItemCreated {
id: ID!
title: String!
creatorId: RefID!
@allain
allain / dreamcode1.js
Last active July 25, 2020 23:34
Dreamcoding an Event Sourced DDD JavaScript Library
import { App, Event, Problem, Reducer, Validator } from '.'
const app = App()
// an reducer middleware that places the reduction on the context
const statsReducer = Reducer(
'stats',
({count, total, min, max}, event) => {
switch (event.name) {
case 'recorded':
@allain
allain / auto-fill.js
Last active May 23, 2020 18:14
Script to auto-fill a form
function insertJquery() {
let loaded = false
if (loaded) return Promise.resolve(jQuery)
return new Promise(resolve => {
const scriptEl = document.createElement('script')
scriptEl.setAttribute('src', 'https://code.jquery.com/jquery-3.5.1.min.js')
scriptEl.setAttribute('integrity', "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=")
scriptEl.setAttribute('crossorigin', 'anonymous')
scriptEl.onload = () => {
@allain
allain / mergeRequests.js
Last active June 26, 2019 15:28
merges GraphQL requests
import { parse, print, visit } from "graphql"
export default function mergeRequests(requests) {
const numberedAsts = requests.map(({ query }, index) => {
let ast = parse(query)
ast = numberVars(ast, index)
ast = numberSelectionSet(ast, index)
return ast
})
@allain
allain / delete-node-modules.sh
Created May 9, 2019 13:51
remove all node_modules recursively
#!/bin/bash
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +