Skip to content

Instantly share code, notes, and snippets.

View timkinnane's full-sized avatar

Tim Kinnane timkinnane

View GitHub Profile
@timkinnane
timkinnane / .zshrc
Created September 25, 2022 04:45
Shell alias for PNPM install, including workspace filters.
alias p="pnpm add"
alias pf="pnpm add --filter"
alias pd="pnpm add -D"
alias pdf="pnpm add -D --filter"
alias pi="pnpm i"
@timkinnane
timkinnane / README.md
Last active September 14, 2022 15:26
Apply branch name format check on commits

Enforce branch name conditions with git hooks

The pre-commit git hook tests branch name against a text pattern.

If commits don't match the pattern, they will error and contributors will have the opportunity to rename the branch before trying to commit again.

Patterns

The example pattern ensures branch names are:

  • scoped by type of change and team owner
@timkinnane
timkinnane / construct.ts
Created March 16, 2022 05:23
AWS CDK SSM: A construct for accessing SSM values from a stack as Cloud Formation tokens to resolve on deploy.
import { Construct } from 'constructs'
import { aws_ssm as SSM } from 'aws-cdk-lib'
/**
* Create a resource for accessing SSM values (as Cloud Formation tokens to resolve on deploy).
*/
export class ParamsConstruct extends Construct {
private configPath: string
private secretPath?: string
@timkinnane
timkinnane / fp-util-types.ts
Last active February 14, 2023 16:42
Typescript Generic Utils for Functional Programming
/**
* Make all optional except given keys.
* @example
* type ABC = { a: any, b: any, c: any }
* type OnlyAB = Only<ABC, 'a' | 'b'>
* // ☝️ OnlyAB = { a, b, c? }
*/
export type Only<T, K extends keyof T> = Partial<T> & Required<Pick<T, K>>
/**
@timkinnane
timkinnane / clientcommands.md
Last active June 26, 2018 00:28 — forked from mikaelmello/clientcommands.md
Client Commands

I'd like to introduce a new utility called Client Commands, a solution created to allow the Rocket.Chat server to trigger actions in subscriber clients (bots and possibly other websocket clients). This is handled at the adapter and/or SDK level, not by final users (e.g. normal bot developers).

The problem

Bots subscribe to a message stream and respond to message events, but there's no way for the server to prompt them to do anything other than that.

In order to provide a range of new management features for administrating bot clients, getting data or triggering any non message response action, we need to send data to be interpreted by the client as a command. Such data, identified here by ClientCommands, could not be sent through the normal message stream, because:

  • a) it would go to everyone, not just bot clients
  • b) it would need hack workarounds to filter commands from normal message data
  • c) it would be kept forever, bloating message collection storage
@timkinnane
timkinnane / blockstack_verification.txt
Created January 18, 2018 02:51
Blockstack verification
Verifying my Blockstack ID is secured with the address 1Htvmm5DbsDJCSSRuHByX4YJbEkGHtpTY7 https://explorer.blockstack.org/address/1Htvmm5DbsDJCSSRuHByX4YJbEkGHtpTY7
@timkinnane
timkinnane / demo.html
Created June 24, 2015 13:59
Email auto-suggest (by Stuart Taylor) http://codepen.io/stuarttayler/pen/NPdXrq
<div id="wrapper">
<header class="group">
<h1>Email auto-suggest</h1>
<p id="author" class="group">By Stuart Tayler</p>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="stuarttayler1" data-count="none">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</header>
<p>Email address</p>
<div id="placement">
add_action('save_post', 'wpds_check_thumbnail');
add_action('admin_notices', 'wpds_thumbnail_error');
function wpds_check_thumbnail($post_id) {
// change to any custom post type
if(get_post_type($post_id) != 'post')
return;
if ( !has_post_thumbnail( $post_id ) ) {
@timkinnane
timkinnane / database_table_example.php
Last active July 21, 2022 13:31
Take a WPDB query result and display it as a table, with headers from data keys. Creates demo menu page to show example table. #wordpress Basic example for previewing results, handy for debugging etc, but doesn't provide much validation, sorting, pagination etc.
<?php
/**
* Take a WPDB query result and display it as a table, with headers from data keys.
* This example only works with ARRAY_A type result from $wpdb query.
* @param array $db_data Result from $wpdb query
* @return bool Success, outputs table HTML
* @author Tim Kinnane <tim@nestedcode.com>
* @link http://nestedcode.com
*/