Skip to content

Instantly share code, notes, and snippets.

View arleighdickerson's full-sized avatar
🇺🇲
✡️

Arleigh Dickerson arleighdickerson

🇺🇲
✡️
View GitHub Profile
import lombok.NonNull;
import lombok.SneakyThrows;
import org.apache.commons.codec.binary.Base32;
import org.springframework.lang.Nullable;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Pattern;
import io.arleigh.gantry.cache.PrefixedKeyGenerator;
import io.arleigh.gantry.properties.AppRedisProperties;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.val;
import org.redisson.api.RedissonClient;
import org.redisson.jcache.configuration.RedissonConfiguration;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.core.RedisKeyValueAdapter;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import org.springframework.session.data.redis.config.ConfigureRedisAction;
// https://dzone.com/articles/build-a-chat-application-using-spring-boot-websock
// https://engineering.salesforce.com/lessons-learned-using-spring-data-redis-f3121f89bff9
// https://help.heroku.com/5BP0E8RC/how-to-enable-notify-keyspace-events-on-redis
import io.undertow.connector.ByteBufferPool;
import io.undertow.server.DefaultByteBufferPool;
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Configuration;
@Configuration
class UndertowConfig implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> {
@arleighdickerson
arleighdickerson / inversify-provider.tsx
Created December 12, 2024 17:52
inversify-provider.tsx
import { AsyncContainerModule, Container as ContainerImpl, ContainerModule } from 'inversify';
import { Provider as IocProvider } from 'inversify-react';
import _ from 'lodash';
import { PropsWithChildren, useEffect, useState } from 'react';
const context = require.context('src', true, /\.config\.ts$|\.config\.tsx$|\.saga\.ts|\.events\.ts$/, 'lazy-once');
const keys = context.keys();
const getApplicationContext = _.once(async () => {
const container = new ContainerImpl({ defaultScope: 'Request' });
package com.teletapper.actuator;
import com.teletapper.util.SecurityUtils;
import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpoint;
import { useEffect } from 'react';
const bpmToMillis = (bpm: number) => (bpm === 0 ? 0 : Math.round(60000.0 / bpm));
let vibrateInterval: number;
function startVibrate(duration: number) {
navigator.vibrate([duration, duration]);
}
import { Channel, NotUndefined } from '@redux-saga/types';
import { Buffer, channel, EventChannel, Saga } from 'redux-saga';
import * as effects from 'redux-saga/effects';
import _ from 'lodash';
import { cast, isInteger } from 'src/util/invariant';
export type THandleRequest<T extends NotUndefined> = Saga<[Channel<T>]>;
export type TCreatePipe<T extends NotUndefined> = Saga<[EventChannel<T>, Saga<[Channel<T>]>]>;
export interface CreatePipeOptions {
@arleighdickerson
arleighdickerson / uuid-util.ts
Created March 11, 2024 19:48
Utilities for uuids on the client side.
import _ from 'lodash';
export namespace uuidUtil {
const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
export function isValidUuid(s: string) {
if (!_.isString(s)) {
return false;
}
if (_.isEmpty(s)) {
@arleighdickerson
arleighdickerson / url-util.ts
Created March 11, 2024 19:46
Utilities for working with preact-router
const { exec, getCurrentUrl } = require('preact-router');
export namespace urlUtil {
export const getUrlParameter = (name: string, location: Pick<Location, 'pathname' | 'search'>): string | null => {
if (typeof window === 'undefined') {
return null; // shim
}
const a = 'http://localhost' /* <-- dummy string for parsing */ + location.pathname + location.search;
const url = new URL(a);
return url.searchParams.has(name) ? url.searchParams.get(name) : null;