Skip to content

Instantly share code, notes, and snippets.

View snewell92's full-sized avatar
😺
Workin' and Livin'

Sean Newell snewell92

😺
Workin' and Livin'
View GitHub Profile
@snewell92
snewell92 / container_override.py
Last active December 7, 2023 17:06
Wireup DI Override
from typing import (
Any,
Dict,
Generic,
Literal,
Optional,
Tuple,
TypeVar,
)
from wireup import DependencyContainer, container
@snewell92
snewell92 / authentication.ts
Last active July 23, 2023 11:35
Sample Feathers routing with express like a traditional semi-session option
import authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const extractJWT = jwt.ExtractJwt;
import { Application } from 'feathers';
import { Request } from 'express';
// !! This service is different than the default.
@snewell92
snewell92 / filtered_to_jq.sh
Last active May 25, 2023 07:42
Conditionally pass to jq if the line looks a bit like jason
#!/bin/zsh
# Conditionally pass line or file data to jq.
#
# First argument is a filter override to jq, default is '.'
# Second argument is a file, otherwise stdin is used
JQ_FILTER=${1:-'.'}
while read line
@snewell92
snewell92 / cli.ts
Created April 3, 2023 20:20
ChatGPT Prompt for overload issue
import cli, { InputQuestion, ListQuestion } from "inquirer";
interface TypeSafeInput<
TValidatedInput,
TName extends string
> extends InputQuestion<{ [name in TName]: TValidatedInput }> {
type: "input";
name: TName;
message: string;
typePredicate: (input: any) => input is TValidatedInput;
@snewell92
snewell92 / mysql.js
Created June 2, 2017 16:01
Sequelize ES6 model syntax
var Promise = require('bluebird');
const Sequelize = require('sequelize');
const fs = Promise.promisifyAll(require('fs'));
const _ = require('lodash');
const sequelize = new Sequelize(connectionString, {
dialect: 'mysql',
logging: false,
pool: { // application-side connection pool configuration
@snewell92
snewell92 / ResponsiveService.js
Last active May 11, 2021 21:35
Angular Responsive Service
/* TYPESCRIPT */
import { Injectable } from '@angular/core';
@Injectable()
export class ResponsiveService {
constructor() {
window.onresize = this.callSubscribers
}
@snewell92
snewell92 / my-dict.ts
Last active September 28, 2018 02:19
Typescript Dictionary
type KEY = string | number | symbol;
interface Dictionary<K extends KEY, V> {
getKeys(): K[];
getValues(): V[];
get(key: K): V | null;
put(key: K, val: V): void; // or boolean?
}
class JSDict<K extends KEY, V> implements Dictionary<K, V> {
@snewell92
snewell92 / test-app.docker-compose.yml
Last active March 11, 2018 00:01
basic http traefik
version: "2"
services:
app:
image: crccheck/hello-world
restart: always
networks:
- web
- default
expose:
@snewell92
snewell92 / api-server.js
Last active March 8, 2018 21:21
Feathers JWT doesn't have userID
// CLIENT
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import auth from '@feathersjs/authentication-client'
import io from 'socket.io-client'
const socket = io('http://localhost:3030')
const app = feathers()
// Set up Socket.io client with the socket
@snewell92
snewell92 / Continuation.js
Created February 28, 2018 16:03
Some thing to map but stop on a failure
class ContinueOnSuccess {
items = [];
length = 0;
constructor(newItems) {
this.items = newItems;
length = this.items.length;
}