Skip to content

Instantly share code, notes, and snippets.

@overthemike
overthemike / typenarrow.md
Created April 25, 2025 04:21
runtime type narrowing

typeof operator

const processValue = (value: string | number) => {
  if (typeof value === 'string') {
    // TypeScript knows 'value' is a string here
    return value.toUpperCase();
  } else {
    // TypeScript knows 'value' is a number here
    return value.toFixed(2);
  }
@overthemike
overthemike / descunion.ts
Last active April 25, 2025 04:32
Initializing state without known values
// Descriminated Union
type DataState<T> =
| { status: 'loading' }
| { status: 'error', error: Error }
| { status: 'success', data: T }
interface User {
name: string
age: number
}
@overthemike
overthemike / instructions.md
Created November 4, 2024 23:00
ClubWPT chat - split dealer and player messages
  1. After you go to a table, right click on the table and click "Inspect".
  2. On the right (usually), click on the "Console" tab.
  3. Copy and paste the file above into the console and hit enter.
  4. You can close the inspector by clicking the X on the top right.

You'll need to do this every time you go to a new table for now. I'll eventually turn this into an extension for chrome with a lot more enhancements. If you have any suggestions for more featues, please comment them below.

Future Features: Ignore specific user in chat.

import { Router } from "express"
import ejwt from "express-jwt"
import config from "config"
import createError from "http-errors"
import publicRouter from "./public"
import protectedRouter from "./protected"
console.log(protectedRouter)
const router = Router()
-- INSERT
INSERT INTO tablename (column1, column2, column3)
VALUES
('value1', 'value2', 'value3'),
('value4', 'value5', 'value6');
-- UPDATE
UPDATE tablename
SET
column1 = 'value1'
#!/bin/bash
NC='\033[0m' # No color
BLACK='\033[00;30'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
var I = (function(){
var events = {}
function subscribe(event, fn) {
if (events.hasOwnProperty(event)) {
events[event].push(fn)
} else {
events[event] = [fn]
}
}
const gulp = require('gulp')
const buildCSS = require('./semantic/gulpfile').buildCSS
const fs = require('fs')
const varfiles = fs.readdirSync('files')
gulp.task('build-css', function build(done){
run()
})
import React, { Component } from 'react'
import { Route, Redirect } from 'react-router-dom'
import AuthService from '../lib/auth'
export const api = new AuthService()
const AuthContext = React.createContext({
isAuthenticated: false,
redirectUrl: '/login',
defaultRedirect: '/'
import React from 'react'
import { BrowserRouter as Router, Route, Link, Redirect } from 'react-router-dom'
import { Authentication, AuthRoute } from './Authentication'
import Login from './Login'
import Public from './Public'
import Protected from './Protected'
const App = props => (
<Router>
<Authentication