Skip to content

Instantly share code, notes, and snippets.

View RobinDaugherty's full-sized avatar

Robin Daugherty RobinDaugherty

View GitHub Profile
RobinDaugherty /
Last active January 5, 2024 11:18
Locate dangling git commit containing a matching file path
for sha in $(git fsck --no-reflog | awk '/dangling commit/ {print $3}'); do
if git show --name-only $sha | grep -q 'apollo-codegen'; then
echo "Found in $sha";
git log -n 1 $sha;
RobinDaugherty / instrumented.rb
Last active July 12, 2022 15:25
Instrumented module that uses Appsignal to migrate from Instrumental
# typed: true
# frozen_string_literal: true
# Light wrapper around AppSignal's metric methods, providing some helpers similar to Instrumental's (RIP)
# library.
# Important: Metric names should never be dynamic!
# AppSignal is able to take tags as part of instrumentation which can provide granularity that the metric name
# does not provide.
# But when tags are specified in an event, it's not possible to graph or evaluate the aggregate, so we must
# frozen_string_literal: true
class ApplicationEnvironment
def initialize(rails_env:, application_env:)
@name = if rails_env == 'test'
elsif rails_env == 'development'
elsif rails_env == 'staging' || (rails_env == 'production' && application_env == 'staging')
RobinDaugherty / App.tsx
Created September 10, 2020 19:44
React app with router and error boundary
import React from 'react';
import { IntlProvider } from "react-intl"
import { AuthenticationProvider, AuthenticationRequired } from "lib/Authentication"
import ApolloClientProvider from "lib/ApolloClient";
import ErrorBoundary from "boundaries/ErrorBoundary";
import PageNotFoundBoundary from "boundaries/PageNotFoundBoundary";
import { Router, Routes } from "./Routes";
import PageLayout from "components/PageLayout";
const App: React.FC = () => {
RobinDaugherty / ApolloClient.ts
Last active July 19, 2022 21:11
Apollo client setup with ActionCable using TypeScript
import ActionCable from 'actioncable';
import { ActionCableLink } from 'graphql-ruby-client';
import { ApolloClient } from "apollo-client";
import { ApolloLink, Operation } from "apollo-link";
import { DefinitionNode, OperationDefinitionNode } from 'graphql';
import { RetryLink } from "apollo-link-retry";
import { createHttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import { onError } from "apollo-link-error";
# frozen_string_literal: true
# notification :terminal_notifier
ignore %r{^(tmp|log|run|bin)/}
# guard 'migrate', test_prepare: true do
# watch(%r{^db/migrate/(\d+).+\.rb})
# watch('db/seeds.rb')
# end
RobinDaugherty /
Last active April 12, 2023 05:22 — forked from nmurthy/getTotps.js
Authy OTP Export

If you fork and modify this gist, please add a note (to the bottom) about what you changed.

  • Detect the "period" instead of assuming 10 seconds (which was incorrect) or deriving the period based on the number of digits. (@RobinDaugherty 2020-01-16)
  • Show a warning about Authy proprietary OTPs, which are unsupported in other apps at this time. If any other app supports these, please comment about it. (@RobinDaugherty 2020-01-16)
  • Added QR Code to the console directly so that the OTP secret isn't sent to Google. This came from @Puddly (@RobinDaugherty 2020-01-17)
  • Fixed proprietary Authy codes (used by Twilio and Cloudflare for example) using the fix from @Puddly
RobinDaugherty / jsonapi.jbuilder
Created March 29, 2019 15:51
JSONAPI with jbuilder
# returning a set of objects
included_records = [] do # => data:
json.array! orders do |order| # => []
json.type "order"
json.(order, :id)
json.attributes do
json.(order, :name)
RobinDaugherty / .codacy.yml
Created January 29, 2019 15:42
Flowspace Codacy config
enabled: true
- spec/
enabled: true
- spec/
RobinDaugherty / generators-service-USAGE
Last active June 22, 2022 08:30
Rails generator for services and lib objects
Stubs a new Service object in the `lib` folder and a spec for it.
Providing a list of argument names will set up the initializer to accept them
and create private accessors for each of them.
To create a service within a module, specify the service name as a
path like 'parent_module/service_name' or 'ParentModule::ServiceName'.