Experiment for creating .drl
drill files.
These are used in the process of fabricating PCBs (printed circuit boards), they specify where the laser/mechanical drills should drill holes.
The format is also known as Excellon.
/* | |
It's now a package. You can find it here: | |
https://github.com/joshnuss/svelte-local-storage-store | |
*/ | |
// Svelte store backed by window.localStorage | |
// Persists store's data locally |
# define a record, first attribute is considered the key | |
defrecord User, email: "", first: "", last: "" | |
# encapsulates mnesia calls | |
defmodule Database do | |
def create_schema do | |
create_table User | |
end | |
def find(record, id) do |
// the main app file | |
import express from "express"; | |
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
import authenticate from "./authentication"; // middleware for doing authentication | |
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request | |
const app = express(), | |
api = express.Router(); | |
// first middleware will setup db connection |
import { expect } from 'vitest' | |
expect.extend({ | |
async toError(promise, status, message=null) { | |
try { | |
await promise | |
return { pass: false, message: () => 'Expected an error to be raised.'} | |
} catch (actual) { | |
if (actual?.constructor?.name !== 'HttpError') { |
# Preloading usually required an extra query. | |
# To do it in one query, a `join` is needed, and the call to `preload` needs to know the name of join | |
# This macro does both the `join` and `preload` together | |
defmodule Preloader do | |
import Ecto, only: [assoc: 2] | |
alias Ecto.Query.Builder.{Join, Preload} | |
defmacro preload_join(query, association) do | |
expr = quote do: assoc(l, unquote(association)) | |
binding = quote do: [l] |
import fetch from 'node-fetch' | |
// some provider data is copied from github.com/simov/grant | |
const providers = { | |
bogus: { | |
authorize_url: "http://localhost:8282/auth/request/path", | |
access_url: "http://localhost:8282/access/token/request", | |
}, | |
google: { |
Experiment for creating .drl
drill files.
These are used in the process of fabricating PCBs (printed circuit boards), they specify where the laser/mechanical drills should drill holes.
The format is also known as Excellon.
import { writable } from 'svelte/store' | |
// returns a store with HTTP access functions for get, post, patch, delete | |
// anytime an HTTP request is made, the store is updated and all subscribers are notified. | |
export default function(initial) { | |
// create the underlying store | |
const store = writable(initial) | |
// define a request function that will do `fetch` and update store when request finishes | |
store.request = async (method, url, params=null) => { |
# to run: | |
# > elixir --no-halt udp_server.exs | |
# to test: | |
# > echo "hello world" | nc -u -w0 localhost 2052 | |
# > echo "quit" | nc -u -w0 localhost 2052 | |
# Let's call our module "UDPServer" | |
defmodule UDPServer do | |
# Our module is going to use the DSL (Domain Specific Language) for Gen(eric) Servers | |
use GenServer |
/* | |
* Using digital hall effect sensor SENS-M-10 (purchased at Abra) | |
* | |
* MCU Board: ESP2-WROOM-32 | |
*/ | |
#include <BLEDevice.h> | |
#include <BLEUtils.h> | |
#include <BLEServer.h> |