Skip to content

Instantly share code, notes, and snippets.

View joeyguerra's full-sized avatar
😀
chatting

Joey Guerra joeyguerra

😀
chatting
View GitHub Profile
@joeyguerra
joeyguerra / env-variable-pwsh
Created January 20, 2024 17:21
How to set an environment variable in Windows/PowerShell at the prompt.
$env:DEBUG="hubot:*"
@joeyguerra
joeyguerra / gif-gen.sh
Created January 12, 2024 13:55
create a gif from a Mac OS screen cast
#!/usr/bin/env bash
ffmpeg -i /Users/joeyguerra/Desktop/Screen\ Recording\ 2024-01-10\ at\ 1.37.01 PM.mov -vf "fps=10,scale=640:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 out.gif
@joeyguerra
joeyguerra / StreamListener.cs
Created December 3, 2022 18:09
Listen to Redis streams
using StackExchange.Redis;
namespace Shipment;
public class StreamListener
{
private readonly ConnectionMultiplexer _multiplexer;
private string _consumerGroupName;
public StreamListener(ConnectionMultiplexer multiplexer, string consumerGroupName)
@joeyguerra
joeyguerra / ignore-cert.mjs
Created March 20, 2023 16:12
Ignore the cert when making an HTTPS request to a self-signed service.
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
using MongoDB.Bson;
public static class BsonDocumentExtentions
{
public static void RemoveNullElements(this BsonDocument documents)
{
RemoveNulls(documents);
}
public static BsonDocument RemoveNulls(BsonDocument document)
{
@joeyguerra
joeyguerra / startredis.sh
Last active June 2, 2022 15:15
Run Redis as a docker container
docker run --rm -p 6379:6379 -d --name myredis -v $(pwd):/data redis redis-server --requirepass $(REDIS_PASSWORD) --appendonly yes
@joeyguerra
joeyguerra / relative-dir.mjs
Created April 27, 2022 18:20
Reliably get relative path in Node.js
import { fileURLToPath } from 'url'
const dirName = fileURLToPath(import.meta.url).replace('/bin/hubot.mjs', '')
@joeyguerra
joeyguerra / schema.js
Last active April 8, 2022 15:14
Schema.org microdata parser in Javascript for the client side.
(function(win){
/*
Copied from https://github.com/foolip/microdatajs/blob/master/jquery.microdata.json.js
without jQuery.
*/
var Schema = (function(doc){
function getTypes(node){
var type = node.getAttribute('itemtype');
if(!type) return [];
return type.split(' ');
@joeyguerra
joeyguerra / git-serve
Created April 1, 2022 14:59
Allow other people to clone repos from your local machine.
git daemon --verbose --export-all --base-path=. --reuseaddr
@joeyguerra
joeyguerra / IntegrationTestForRedisPubSub.cs
Last active March 7, 2022 16:27
Integration test for Redis Pub/Sub
[Fact]
public async void ShouldPublishResultMessage()
{
var messageContract = File.ReadAllText("MessageContract.json");
var expected = JsonSerializer.Deserialize<Result>(messageContract);
var subscriber = _fixture.RedisPersistence.GetSubscriber();
var tcs = new TaskCompletionSource<Result>();
subscriber.Subscribe("channel:result", (channel, message) =>
{
var result = JsonSerializer.Deserialize<Result>(message);