Skip to content

Instantly share code, notes, and snippets.

View atengberg's full-sized avatar

atengberg atengberg

  • sidereal
View GitHub Profile
@atengberg
atengberg / EPSgen.js
Last active April 12, 2024 23:31
Of all the eager settled promises.
/*
Always interesting when while working on a specific problem resolution,
coincidentally the circle gets squared. In this case, while building one thing,
it lead down the rabbit hole of async generators which surveyed everything from
https://www.dreamsongs.com/WorseIsBetter.html to https://okmij.org/ftp/Streams.html
and much, much more until it led back to an SO post that had a related SO post that
was quite literally almost the same thing I had originally set out to build (!).
I should probably compile all the bookmarks for any potential shared future benefit,
but note this particular generator function is almost *entirely* modeled on the work of Redu from:
@atengberg
atengberg / zx_for_redis-server_dev.js
Last active March 4, 2024 18:44
(Somewhat naive) Approach to using ZX for managing redis server during node project development
// Using zx to manage background redis server (for development purposes mostly, and doesn't require sudo (except prior to, when disabling redis-server autoboot initially)).
// ( cli user input loop logic via zx question likely suggests its own reusable component TBD; also something similar for zx error handling).
// notice while redis-server cmd is used to start, to cleanly stop redis-cli shutdown is used. Avoids manipulating systemctl (as I saw on several guides) which when doing so tended to spontaneousily crash my system).
// in reverse order for readible coherence, all relative directories flattened for simplicity.
// assume npm esm project... with a script defined:
// npm script: "redis-server": "node index.js" (see below)
@atengberg
atengberg / bounty-task-checklist.md
Last active February 16, 2023 01:26
bnt-2 invoice canister completed bounty-task checklist

BNT-2 - Invoice Bounty Task Check Sheet

This is a list of all the tasks specified as part of the bounty to be completed before submission for approval.

They can be originally found at BNT-2: Invoice Canister #2.

This was created to make it easier to know what needed to be done as to verify everything has been completed.


@atengberg
atengberg / comment-example.mo
Last active February 14, 2023 21:45
comment level verbosity
Example A (**verbose in-method-body comments**)
public shared ({ caller }) func verify_invoice(
{ id } : Types.VerifyInvoiceArgs,
) : async Types.VerifyInvoiceResult {
switch (getInvoiceIfAuthorized(invoices.get(id), caller, #Verify)) {
// Caller is not authorized or invoice not found.
case (#err err) return #err(err);
// Caller is creator or on invoice's verify permissions list.
case (#ok invoice) {
@atengberg
atengberg / MockTokenLedgerCanisters.mo
Last active February 14, 2023 21:22
icp or icrc1 ledger canister that can be used to mock icp or icrc1 token-ledger canisters
You can drop the ICP.MockLedger if you want to skip importing the Aviate Labs libraries and just use it for ICRC1.
MockTokenLedgerCanisters.mo...
```
import Array "mo:base/Array";
import Blob "mo:base/Blob";
import Buffer "mo:base/Buffer";
import Debug "mo:base/Debug";
import Error "mo:base/Error";
import HashMap "mo:base/HashMap";
@atengberg
atengberg / using zx for dfx
Last active January 25, 2023 19:14
an example of using zx to deploy an icrc1 ledger with a esm utility function and run dfx nns install after checking if networks config is correct
uses zx as ilocal project dependency; zx can also
be used by including its shebang at the beginning
of the mjs using it--in that case can be run by
> chmod +x file.mjs
> zx file.mjs
⸎⸖------------------------------------------------------------------------⸖⸎
./zx-scripts/generate_icrc1_deployment_literal.mjs:
<start of file>
@atengberg
atengberg / new_gist_file_0
Last active February 14, 2023 22:04
what is oo
What is objected orientated programming?
"Object oriented programming is a technique of writing code that encapsulates complexity by enumerating data structures with an intrinsic implementation so that they can generally interface."
@atengberg
atengberg / new_gist_file_0
Created December 15, 2014 10:19
copy file from raw resource
private void copyFile(String fromPath, String fileName, int file) {
InputStream in = null;
OutputStream out = null;
try {
in = getResources().openRawResource(file);
out = new FileOutputStream(new File(fromPath, fileName));
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
.DS_Store
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files