Skip to content

Instantly share code, notes, and snippets.

View joeyguerra's full-sized avatar
😀
chatting

Joey Guerra joeyguerra

😀
chatting
View GitHub Profile
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
@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);
@joeyguerra
joeyguerra / init-existing-repo.sh
Created November 7, 2021 21:25
New Github project with existing code on local machine
#!/bin/zsh
# example run: ./init.sh git@github.com:joeyguerra/100-days-of-code.git
git init
git remote add origin $1
git add .
git commit -m "initial commit"
git push -u origin main
@joeyguerra
joeyguerra / dredis-cli.sh
Last active November 6, 2021 16:09
Connect to locally running Redis Server with Docker Container
docker run --rm -it --name redis-cli redis redis-cli -h $IPADDRESS -a $REDIS_PASSWORD
@joeyguerra
joeyguerra / getbitcoin.js
Created January 9, 2021 04:24
BitCoin price
Notification.requestPermission();
setInterval(async ()=>{
let data = await (await fetch("https://api.coindesk.com/v1/bpi/currentprice.json")).json();
document.body.innerHTML = `${data.time.updated}:%20${data.bpi.USD.rate}`;
if(Notification.permission == "granted") new Notification(`BitCoin Price: $${data.bpi.USD.rate}`);
},10000);
import assert from "assert"
import http2 from "http2"
//using mocha
describe("Http2", ()=>{
it("Should make a get request to google with http2", done => {
const uri = "https://www.google.com"
const client = http2.connect(uri);
const req = client.request({
[http2.constants.HTTP2_HEADER_SCHEME]: "https",
[http2.constants.HTTP2_HEADER_METHOD]: http2.constants.HTTP2_METHOD_GET,
@joeyguerra
joeyguerra / ParseEnvFile.mjs
Created September 5, 2020 02:46
Parse a .env file key/value pairs
import assert from "assert"
describe("PropertyFile - externalize configuraiton with environment variables", ()=>{
it("Should parse an env file", async done => {
const env = `
CLIENT_ID="something"
CLIENT_SECRET="something"
# something id
ID=1
`
let config = {}
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x)

Keybase proof

I hereby claim:

  • I am joeyguerra on github.
  • I am joeyguerra (https://keybase.io/joeyguerra) on keybase.
  • I have a public key ASBDxkxeKV2rhI1xg9U9HoLNphwjWh_qk2Sj5V969ys6fAo

To claim this, I am signing this object:

@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(' ');