Skip to content

Instantly share code, notes, and snippets.

View kyle-mccarthy's full-sized avatar

Kyle McCarthy kyle-mccarthy

  • St. Louis, United States
View GitHub Profile
@kyle-mccarthy
kyle-mccarthy / Cargo.toml
Created July 19, 2023 01:26
Tonic bidirectional stream client utility
[package]
name = "tonic-stream-wrapper"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["sync"] }
@kyle-mccarthy
kyle-mccarthy / createSlice.ts
Last active June 27, 2024 01:23
namespaced slices in zustand
import type { GetState, PartialState, SetState, State } from "zustand";
const noop = (..._: unknown[]): void => {
/* noop */
};
export type Setter<T extends State> = (
s: Partial<T> | ((prev: T) => Partial<T>),
replace?: boolean
) => void;
@kyle-mccarthy
kyle-mccarthy / main.rs
Created April 22, 2021 22:56
pull messages from Google PubSub using rust
use google_pubsub1::{api::AcknowledgeRequest, Pubsub};
use std::fs::File;
use std::io::BufReader;
use yup_oauth2::ServiceAccountKey;
static SUBSCRIPTION_PATH: &'static str =
"projects/PROJECT_ID/subscriptions/SUBSCRIPTION";
static ACCOUNT_KEY = &'static str = "YOUR_ACCOUNT_KEY.json";
#[tokio::main]
@kyle-mccarthy
kyle-mccarthy / compound3.sdf
Created January 20, 2021 17:03
SDF file example (Chemical table file) from pubchem
3
-OEChem-01172103382D
19 19 0 1 0 0 0 0 0999 V2000
5.1350 1.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
6.8671 0.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
2.5369 -0.1550 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
3.4030 1.3450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
5.1350 0.3450 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
6.0010 -0.1550 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
@kyle-mccarthy
kyle-mccarthy / cache-config.service.ts
Created February 20, 2020 20:48
nest.js cache config for redis
import {
CacheModuleOptions,
CacheOptionsFactory,
Injectable,
} from '@nestjs/common';
import { LoggerService } from '@src/common/logger.service';
import { ConfigOptions, ConfigService } from '@src/config/config.service';
import * as redisCacheStore from 'cache-manager-redis-store';
@Injectable()
@kyle-mccarthy
kyle-mccarthy / gaLinkDecorator.js
Created January 17, 2019 20:04
Decorate outbound link for cross domain tracking
const decorateLink = (destinationUrl) => {
if (ga !== undefined && typeof ga.getAll === 'function') {
const trackers = ga.getAll();
if (trackers.length > 0) {
const linker = new window.gaplugins.Linker(trackers[0]);
return linker.decorate(destinationUrl);
}
}
return destinationUrl;
}
@kyle-mccarthy
kyle-mccarthy / ScrolllockComponent.jsx
Created February 7, 2018 17:45
React locking of body scroll for desktop and touch devices
import React from 'react';
const withScrolllock = (WrappedComponent) => {
return class ScrolllockComponent extends React.Component {
constructor(props) {
super(props);
this.y = null;
this.ref = null;
}
@kyle-mccarthy
kyle-mccarthy / GsappedComponent.jsx
Last active February 7, 2018 17:40
GSAP HOC React
import React from 'react';
import { TimelineLite, TweenLite } from 'gsap';
const asGsapped = (WrappedComponent) => {
return class GsappedComponent extends React.PureComponent {
constructor(props) {
super(props);
}
@kyle-mccarthy
kyle-mccarthy / callrailGoogleMaps.js
Last active February 7, 2018 17:35
Modify Google Maps with Callrail numbers
var callrailGoogleMaps = {
getNumbers: function() {
var self = this;
window.CallTrk.getSwapNumbers(null, function(nums) {
self.swapNumbers(nums);
});
},
getMapPoints: function() {
if (mapping !== undefined) {
return mapping.mapPoint.alllocmap.points;
@kyle-mccarthy
kyle-mccarthy / gtm-config.py
Created August 17, 2017 20:02
Py class for configuring GTM for container based on JSON
import argparse
import sys
import httplib2
import re
import json
from googleapiclient.discovery import build
from oauth2client import client
from oauth2client import file
from oauth2client import tools