Skip to content

Instantly share code, notes, and snippets.

@coxmi
coxmi / Moved
Last active October 19, 2022 09:50
Post-receive script for bare repo
For instructions, go to:
https://github.com/blackbridge/ansible-server/blob/master/docs/README.md
For the raw script, go to:
https://github.com/blackbridge/ansible-server/blob/master/docs/post-receive.sh
@coxmi
coxmi / Example.jsx
Last active June 24, 2021 19:46
jsx-dom self-update component
import { h, Fragment, useRef } from 'jsx-dom'
import { withUpdate } from './withUpdate.js'
const Example = withUpdate(({ update, ...props }) => {
const state = {
value : 'default',
input : useRef(),
...props,
}
@coxmi
coxmi / ConditionalFields.js
Last active April 1, 2024 19:57
Sanity.io conditional field object
import PropTypes from 'prop-types'
import React from 'react'
import Fieldset from 'part:@sanity/components/fieldsets/default'
import { setIfMissing } from 'part:@sanity/form-builder/patch-event'
import { FormBuilderInput, withDocument, withValuePath } from 'part:@sanity/form-builder'
import fieldStyle from '@sanity/form-builder/lib/inputs/ObjectInput/styles/Field.css'
const isFunction = (obj) => !!(obj && obj.constructor && obj.call && obj.apply)
@coxmi
coxmi / getargs.sh
Created January 29, 2020 10:24
shell/bash get arguments alternative to getopts
#!/usr/bin/env bash
# gets arguments/options from input, using `--arg=value`, `--arg value`, or `-a value` format
# doesn't allow doubling up short args, e.g. `-ot`
positional=()
one=
two=
while [ "$#" -gt 0 ]; do
@coxmi
coxmi / ga.js
Last active July 4, 2018 16:57
// can use a random UUID for clientID
// from: https://gist.github.com/jed/982883
function uuid(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,uuid)}
// stops analytics from working at all
window['ga-disable-UA-XXXXX-Y'] = true;
@coxmi
coxmi / Menu.php
Last active June 27, 2023 03:37
Custom wordpress menu: Get menu as hierarchical array with children
<?php
/*
* Helper class to display menu items in a hierarchical array
* Usage: $mainMenu = new Menu('primary');
* $menuItems = $mainMenu->getTree();
* $menuItems = $mainMenu->getMenuItems();
*/
@coxmi
coxmi / info.plist
Created October 1, 2014 16:32
Hide status bar in cordova
boolean UIViewControllerBasedStatusBarAppearance to NO