Skip to content

Instantly share code, notes, and snippets.

@halostatue
halostatue / .licensed.yml
Last active September 15, 2023 15:00
Gem-based test for licensed bug with app_identity
name: bug
allowed:
- mit
apps:
- source_path: .
@halostatue
halostatue / async_assigns.ex
Created June 15, 2023 03:43 — forked from aglassman/async_assigns.ex
LiveView - Async Assigns Helper
defmodule AsyncAssigns do
import Phoenix.LiveView, only: [connected?: 1, assign: 2, assign: 3]
@doc """
Provides ability to assign default values to the socket, and kick off a
process that will send a message to the LiveView. The message payload will
be assigned as specified.
## Usage
Add the following lines to a specific LiveView, or to the web module
@halostatue
halostatue / benchmark_duplicates.exs
Last active April 19, 2023 15:13
Benchmarking duplicate discovery with Elixir
Mix.install([
{:benchee, "~> 1.0"}
])
no_duplicates = [Enum.map(1..10_000, &to_string/1)]
all_duplicates = [no_duplicates, no_duplicates]
some_duplicates = [no_duplicates, Enum.map(300..700, &to_string/1)]
one_duplicate = [no_duplicates, "700"]
minus_minus = fn headers ->
@halostatue
halostatue / safari-nomodule.js
Created October 28, 2022 23:23 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/*
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@halostatue
halostatue / obsidian-web-clipper.js
Last active January 11, 2022 05:29 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([
import("https://unpkg.com/turndown@7.0?module"),
import("https://unpkg.com/@tehshrike/readability@0.2"),
]).then(([{ default: Turndown }, { default: Readability }]) => {
const vault = ""; /* Optional vault name */
const folder = prompt(
"Folder: ",
"Clippings/",
); /* Optional folder name such as "Clippings/" */
const tags = `#clippings ${prompt("Tags", "#to_read")}`; /* Optional tags */
@halostatue
halostatue / machine.js
Last active September 24, 2020 22:24
Generated by XState Viz: https://xstate.js.org/viz
const agentInfo = {
offline: {
on: {
ONLINE: 'online',
GROUP: 'group'
}
},
group: {
on: {
ONLINE: 'online',
@halostatue
halostatue / mjml-2-mjml-and-txt.sh
Created August 6, 2020 13:39 — forked from brasilikum/mjml-2-mjml-and-txt.sh
turn mjml into html and txt.
# Check if mjml is installed
if ! [ -x "$(command -v mjml)" ]; then
echo 'Error: mjml is not installed. Install with "npm install -g mjml"' >&2
exit 1
fi
# Check if html-to-text is installed
if ! [ -x "$(command -v html-to-text)" ]; then
echo 'Error: html-to-text is not installed. Install with "npm install -g html-to-text"' >&2
exit 1
fi
@halostatue
halostatue / backport_pg_10_support_to_rails_4.rb
Created February 21, 2019 04:06
Backport PostgreSQL 10 support to Rails 4.2
require 'active_record/connection_adapters/postgresql/schema_statements'
#
# Monkey-patch the refused Rails 4.2 patch at https://github.com/rails/rails/pull/31330
#
# Updates sequence logic to support PostgreSQL 10.
#
# Monkey patch developed by @replaid: https://github.com/rails/rails/issues/28780#issuecomment-354868174
# put into config/initializers or some other early-loading code.
# config/initializers/backport_pg_10_support_to_rails_4.rb
@halostatue
halostatue / service-checklist.md
Created September 20, 2016 18:19 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@halostatue
halostatue / manyjoin.rb
Created April 26, 2016 20:05
A small issue with many_to_one in nested models
require 'sqlite3'
require 'sequel'
require 'ostruct'
require_relative 'schema'
require_relative 'models'
require 'byebug'
$prime = Catalog.create(name: 'prime')