Skip to content

Instantly share code, notes, and snippets.

@caspg
caspg / 1_searchbar_live.ex
Last active November 6, 2024 11:04
Example of real-time search bar implementation in Phoenix LiveView and Tailwind. Working example on https://travelermap.net/parks/usa
defmodule TravelerWeb.SearchbarLive do
use TravelerWeb, :live_view
alias Phoenix.LiveView.JS
alias Traveler.Places
def mount(_params, _session, socket) do
socket = assign(socket, places: [])
{:ok, socket, layout: false}
end
@fnky
fnky / stripe-keys-and-ids.tsv
Last active October 10, 2024 11:40
Stripe keys and IDs
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
aliacc_ Alipay Account ID Identifier for an Alipay account.
ba_ Bank Account ID Identifier for a Bank Account object.
btok_ Bank Token ID Identifier for a Bank Token object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
@msbarry
msbarry / README.md
Last active June 25, 2024 15:25
Visvalingam vs. Douglas-Peucker

Two well-known algorithms for polyline simplification are the Douglas Peucker and Visvalingam algorithms.

The Douglas Peucker algorithm uses a recursive divide-and-conquer approach. It starts by drawing a straight line from the first point to the last point. Then it finds the intermediate point that is furthest away from the straight line and deems this the "most important" and splits the polyline into two halves at that point. This process is repeated on both halves until the distance of the intermediate point is below a certain threshold, after which all points on that sub-polyline are thrown away since they have a negligible impact on the overall shape.

The Visvalingam algorithm works from the inside-out. It starts by computing the area of the triangle formed by each consecutive three points along the polyline. Then the midpoint of the triangle with the least area is thrown out since those three points are the closest to colinear and the area of triangles on either side are recomputed. The process

@enajski
enajski / base_cf_docs.md
Last active September 26, 2016 15:56
Documentation for Base CRM custom fields
@jeapostrophe
jeapostrophe / explore.rkt
Created July 5, 2012 03:00 — forked from jadudm/explore.rkt
Exploration of the PLT web server...
#lang racket/base
;; Each library function is prefixed by the module it came from.
(require web-server/dispatch)
(define-values (dispatch blog-url)
(dispatch-rules
[("go") go]))
;; dispatch-rules patterns cover the entire URL, not just the prefix,