Skip to content

Instantly share code, notes, and snippets.

View jamesholcomb's full-sized avatar

James Holcomb jamesholcomb

View GitHub Profile
@jamesholcomb
jamesholcomb / ButtonToggleGroup.tsx
Last active October 21, 2023 02:26
From oceanbit
import * as React from "react"
import {
Animated,
View,
Text,
StyleSheet,
Platform,
Pressable,
} from "react-native"
import MaskedView from "@react-native-masked-view/masked-view"
@jamesholcomb
jamesholcomb / ProgressBar.tsx
Created September 10, 2023 13:12
ProgressBar
import React, { useEffect, useState, useCallback } from "react"
import { Animated, StyleSheet, View } from "react-native"
type ProgressBarProps = {
height?: number
progress?: number
animated?: boolean
indeterminate?: boolean
progressDuration?: number
indeterminateDuration?: number
@jamesholcomb
jamesholcomb / index.ts
Created May 20, 2023 16:34
Sort mongodb array of ObjectId
import { Types } from "mongoose"
interface X {
_id: Types.ObjectId
}
const id1 = new Types.ObjectId()
const id2 = new Types.ObjectId()
const id3 = new Types.ObjectId()
@jamesholcomb
jamesholcomb / Setup MongoDB on localhost as Replica Set
Created April 6, 2023 21:48 — forked from davisford/Setup MongoDB on localhost as Replica Set
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
@jamesholcomb
jamesholcomb / build-cse-table.py
Created November 7, 2022 13:36 — forked from desrod/build-cse-table.py
Query Zwift public, upcoming events and build an HTML table of those events (in Python)
There are two parts to this:
1. The main Python code that uses requests + json to parse the events
2. The external Jinja2 template that the data is rendered by, producing the HTML output
# ----------------------------------------------------------------------------------------------------------------
#!/usr/bin/env python3
import json
@jamesholcomb
jamesholcomb / one_liner.sh
Created October 12, 2022 14:21 — forked from zparnold/one_liner.sh
A simply script to delete all failed pods from Kubernetes
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
@jamesholcomb
jamesholcomb / upgrade-node-lts.sh
Created September 29, 2022 15:21
Upgrade node with nvm
#! /usr/bin/env bash
nvm install --lts --reinstall-packages-from=$(nvm current)
@jamesholcomb
jamesholcomb / clone-collection.sh
Created September 19, 2022 14:49
Clones a mongodb collection and its indexes into __collection__
#!/bin/bash
if [[ -z "$1" || -z "$2" ]]
then echo -e "Usage: clone-collection.sh <db> <collection>"; exit 1
fi
# clones a mongodb collection and its indexes into __collection__
mongodump -v -d $1 -c $2 --out=- | mongorestore -v -d $1 -c __$2__ --drop --dir=-
@jamesholcomb
jamesholcomb / index.ts
Last active August 18, 2021 11:58
bullmq missing lock repro
import IORedis from "ioredis"
import { Queue, QueueScheduler, Job, Worker } from "bullmq"
const main = async (): Promise<void> => {
const qs = new QueueScheduler("Paint", {
connection: new IORedis(),
})
const qPaint = new Queue("Paint", {
connection: new IORedis(),
defaultJobOptions: {
@jamesholcomb
jamesholcomb / index.ts
Last active July 9, 2021 19:41
bullmq example showing add job to queue with same jobId
// only one job is added despite removeOnComplete: true
import { Queue, QueueScheduler, Job, Worker } from "bullmq"
const now = () => `[${new Date().toISOString()}]`
const queue = new Queue("Paint", {
defaultJobOptions: {
removeOnComplete: true,
},
})