Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Light elight

  • Heroku
  • Washington, DC
View GitHub Profile
@elight
elight / edate.js
Last active Aug 8, 2022
A tool I wrote to be able to generate a new file from a template and then ![[]] embed the new file into another file. Personally, I use this to embed different checklists into my daily dashboard so that I can track my completion of these tasks over time. But also so that I can hide the embed depnding on the time of day.
View edate.js
// I won't pretend that this is lovely code...
class EDate {
date = null;
vacation = false;
setVacation(v) {
this.vacation = v;
}
// HI SET THIS!!!
@elight
elight / 01utils.js
Last active Jun 5, 2022
Generating mermaid flow diagram based on @elight "project-tagged" Tasks using Obsidian CustomJS and baked in mermaid support
View 01utils.js
class Utils {
escapeRegex(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
}
@elight
elight / tasks_to_flowchart.js
Last active May 29, 2022
DataviewJS for converting multiple tasks with 'project tags' into a mermaid flow chart
View tasks_to_flowchart.js
/**
"Project tags" just means "any markdown task that that share a tag but separates the tasks
identifier/position in the flow followed by the identifiers of the identifiers/positions of
nodes with edges that point to this node. In this way, the tags allow the tasks to remain
sortable by their flow step identifier thusly:
#project/1 step 1 description
#project/2a/1 step 2a description
#project/2b/1 etc
View Pizza.txt
Evan's Foolproof Deep Dish
★★★★★
Pizza
Prep Time: 30 mins. to 50 mins. | Cook Time: 35 mins. to 30 mins. | Difficulty: Medium | Servings: 8
Ingredients:
CRUST
4 cups King Arthur Unbleached All-Purpose Flour
3 tablespoons yellow cornmeal
1 3/4 teaspoons salt
View dns_manager.rb
module API::Clients
class DnsManager < Base
def initialize(url)
headers = {
"Accept" => "application/json",
"Content-Type" => "application/json",
"Request-Id" => API::RequestStore.request_ids,
"X-Request-Id" => API::RequestStore.request_id,
}
super(url, "heroku-dns-manager", headers: headers)
View dns_manager.rb
def params(action:, domain:, target:, type:)
body = {
change: {
:action => action,
"resource-record-set" => {
:name => domain
}
}
}.tap do |b|
case type
View gist:a78c566c5721b44ce794
require 'json'
cert=File.read('cert.pem')
key=File.read('key.pem')
app = "afternoon-citadel-7280"
body = {
app: { id: app },
certificate_chain: cert,
private_key: key
View parameters.rb
def require(key)
self[key].presence || raise(ActionController::ParameterMissing.new(key))
end
alias :required :require
def permit(*filters)
params = self.class.new
View fixture_writer.rb
def fixture_hash
{ identifier => generate_object_attributes }
end
View *.txt
lib/metrics/dashboard.rb:14:9: Rails.cache.fetch("metrics_#{key}_#{interval.to_s}") do
lib/metrics/dashboard.rb:51:9: Rails.cache.write("metrics_#{key}_#{interval.to_s}",data)
lib/metrics/dashboard.rb:56:9: Rails.cache.fetch("#{GROSS_REVENUE_LINE_KEY}-#{period}") do
lib/metrics/dashboard.rb:67:9: Rails.cache.write("#{GROSS_REVENUE_LINE_KEY}-#{period}", data)
lib/metrics/dashboard.rb:73:9: Rails.cache.fetch("#{NET_REVENUE_LINE_KEY}-#{period}") do
lib/metrics/dashboard.rb:91:9: Rails.cache.write("#{NET_REVENUE_LINE_KEY}-#{period}", data)
lib/metrics/dashboard.rb:96:9: Rails.cache.fetch("#{TOTAL_COST_LINE_KEY}-#{period}") do
lib/metrics/dashboard.rb:127:9: Rails.cache.write("#{TOTAL_COST_LINE_KEY}-#{period}", data)
lib/metrics/dashboard.rb:132:9: Rails.cache.fetch("#{CHART_DATA_KEY}-#{interval}") { build_all_chart_data(interval) }.symbolize_keys
lib/metrics/dashboard.rb:136:9: Rails.cache.write("#{CHART_DATA_KEY}-#{interval}", build_all_chart_