Skip to content

Instantly share code, notes, and snippets.

View denisos's full-sized avatar

Denis O'Sullivan denisos

View GitHub Profile
@denisos
denisos / typescript-useful-examples
Last active June 7, 2026 19:29
Typescript examples of useful basic language features
// typeof
// extract a type from runtime code, typeof "make a type of it" (i.e. from it)
// e.g. typeof "Hello world" => string
// only legal on variable names
// can be used with functions or any other expressions
// aside: typeof vs keyof: keyof takes a type and creates a string/number union of it's keys. So keyof creates a new type from a type ....whereas typeof creates a type from an expression. good post
// Given a function below type the function into MyFunc. When the function changes, the types change!
const myFunc = (name: string) => {

Claude code common commands

Type “claude” to start

  • I typically navigate to repo I want to work in first

new (to me) commands

/loop runs any prompt on a recurring schedule. Great for monitoring deploys, babysitting PRs, or polling status.

/*
* ShadowComponent a simple Web Component to render content passed and wrap it in a shadow dom
* why web component? to create shadow dom and isolate html & styles passed in content prop
* usage:
* <shadowcomponent-wc content={html} />
*
* ShadowComponent will rerender when the value passed to content changes.
* content passed is trusted and security is the responsibility of the caller
* references: https://css-tricks.com/building-interoperable-web-components-react/
* https://www.youtube.com/watch?v=vLkPBj9ZaU0
@denisos
denisos / typescriptHints.ts
Created November 28, 2022 05:28
typescript cheatsheet hints
// typing functions
type FocusListener = (isFocussed: boolean) => void
const addListener = (onFocusChanged: FocusListener) => {
return true
}
// type object lietral map, can use
const cache: { [id: string]: string } = {
@denisos
denisos / SalesReport.tsx
Created November 4, 2022 16:53
using react-chartjs to show bar chart and add onClick handler
import React, { useEffect, useState, useRef } from 'react';
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend,
} from 'chart.js';
const berries = ["blackberry", "raspberry", "strawberry"];
const citrus = ["orange", "lime", "mandarin"];
const melons = ["watermelon", "honeydew", "cantalopue"]
let list = [
{
name: "watermelon"
},
{
name: "orange"
},
// example of common basic custom hooks pattern
//
export default function useCounter() {
const [counter, setCounter] = useState(0);
useEffect(() => {
// do something e.g. initialze things
}, [])
* [Interesting Link] [interesting-link]
* [Boring Link] [boring-link]
[interesting-link]: https://github.com/interesting
[boring-link]: https://github.com/boring
@denisos
denisos / gist:7727300
Created December 1, 2013 00:56
angular js directive to show info and handle click
angular.module('directive.contact-brief'
, [])
.directive('contactBrief', [function(Events) {
return {
restrict: 'E',
scope: {
contact:'=contact' // we expect a contact object passed in
},
templateUrl: '../contact-brief.html',
replace: true,
@denisos
denisos / css for no title bar
Created October 5, 2011 17:08
jQuery dialog set button text and no title bar
.noTitleDialog .ui-dialog-titlebar {
display:none;
}