Skip to content

Instantly share code, notes, and snippets.

Brett Dudo dudo

Block or report user

Report or block dudo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View kubernetes.local.md

Tooling for Interacting with a Local Cluster

kubectl

Ingress Controller

This will allow you to visit localhost, simply and it will route based on ports:

View app-constraints-api_constraint.rb
class ApiConstraint
def initialize(options)
@version = options[:version]
@default = options[:default]
end
def matches?(request)
@default || request.headers.fetch(:accept).include?("version=#{version}")
end
end
View csv_serializer.rb
# frozen_string_literal: true
class CsvSerializer
attr_accessor :data
def initialize(serializer)
@serializer = serializer
@data = serializer&.serializable_hash&.dig(:data) || []
end
@dudo
dudo / example.rb
Created Oct 6, 2018
Simple Concern to allow chain-able filtering of ActiveRecord scopes
View example.rb
class Example < ActiveRecord::Base
include Filterable
filterable scopes: %i(search bar)
scope :foo, ->(q) { where(foo: q) }
scope :bar, ->(q) { where(bar: q) }
end
View find_matching_lines_on_plot.rb
# Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
# y = mx + b (Equation of a straight line)
class Plot
attr_accessor :coordinates
def initialize(points=[])
@coordinates = points
View pascal_triangle.rb
class PascalTriangle
attr_accessor :height
def initialize(height)
@height = height.to_i
end
def self.next_row(current_row)
([0] + current_row).zip(current_row + [0]).map{ |a| a.inject(:+) }
View post_fix_calculator.rb
class PostFixCalculator
attr_accessor :list, :original_list
def initialize(list)
@original_list = list
@list = list.split(' ')
end
def evaluation
View audio_spectrum.js
const audio = new AudioContext(),
sound = audio.createMediaStreamSource(stream),
analyser = audio.createAnalyser();
analyser.minDecibels = -60;
// microphone -> filter -> destination.
sound.connect(analyser);
analyser.connect(audio.destination);
const frequencyData = new Uint8Array(analyser.frequencyBinCount).slice(0, 32),
spectrum = document.querySelector('#spectrum');
View tags.rb
class items
has_many :tags, through: :item_tags
has_many :item_tags
belongs_to :city
end
class cities
has_many_ :items
end
You can’t perform that action at this time.