Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Brett Dudo dudo

👋
View GitHub Profile
View deploy_to_cloudfront.yaml
on:
push:
branches:
- master
name: Git Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check_version:
name: Check Version
@dudo
dudo / intrumentation.rb
Last active Feb 22, 2022
Tracing via a macro
View intrumentation.rb
module Instrumentation
DEFAULT_OPERATION = 'method.execution'
def self.trace(operation: DEFAULT_OPERATION, resource:, **options)
options.merge!(resource: resource).compact!
Datadog.tracer.trace(operation, options) do |span|
Datadog::Analytics.set_measured(span)
yield
end
rescue StandardError
@dudo
dudo / fun.css
Created Feb 16, 2022
Collection of nice css snippets
View fun.css
.highlight {
border-radius: 1em 0 1em 0;
background-image: linear-gradient(-100deg, rgba(255,224,0,0.3), rgba(255,224,0,0.7) 95%, rgba(255,224,0,0.1));
}
View step_function.rb
def step(min: 1, comp: 20)
return 0 if min == comp
(1 - (min - comp).abs / (min - comp).to_f) / 2
end
View actions.yaml
name: 'Close stale issues and PR'
on:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
View useViewportSize.js
import { useState, useLayoutEffect } from "react";
export const useViewportSize = (debounceTime = 250) => {
const [viewportSize, setViewportSize] = useState({
width: undefined,
height: undefined
});
const debounce = (fn, ms) => {
let timer;
return () => {
View esbuild.build.js
const { build } = require('esbuild');
const manifestPlugin = require('esbuild-plugin-manifest');
const options = {
entryPoints: ['src/index.js'],
entryNames: '[dir]/[name]-[hash]',
outdir: 'dist',
bundle: true,
minify: true,
plugins: [manifestPlugin()],
View t9.rb
require 'set'
module Trie
class T9
attr_reader :root
def initialize
@root = Hash.new
end
@dudo
dudo / wrapper.rb
Last active Jun 30, 2021
Wrap a method with a macro. Allow for procs to be passed.
View wrapper.rb
module Wrapper
def wrap(method_name, options: {})
proxy = Module.new
proxy.define_method(method_name) do |*args, &block|
options = instance_exec(&options) if options.is_a?(Proc)
target = is_a?(Module) ? "#{self}." : "#{self.class}#"
puts "#{target}#{method_name} is about to be called. `wrap` options #{options}"
super *args, &block
end
self.prepend proxy
@dudo
dudo / .env
Last active Dec 4, 2020
docker-compose example
View .env
# https://github.com/bkeepers/dotenv
COMPOSE_PROJECT_NAME=my_app
REDIS_URL=redis://redis:6379
PGHOST=db
PGUSER=postgres
PGPASSWORD=postgres