Skip to content

Instantly share code, notes, and snippets.

Avatar
🌠
Gradatim

Marco Munizaga MarcoPolo

🌠
Gradatim
View GitHub Profile
@MarcoPolo
MarcoPolo / bufchan.ts
Created Nov 11, 2022
A Go-like buffered channel for JS. Has backpressure
View bufchan.ts
class BufferedChan<T> {
cap: number
sendx = new Uint32Array(2)
recvx = new Uint32Array(2)
buf: { lap: number, val: T | null }[]
closed = false
// Pending senders/receivers
sendq: Array<() => void> = []
View code-server.nix
pkgs.stdenv.mkDerivation
{
name = "code-server";
src = pkgs.fetchurl
(
let
INSTALL_ARCH = "x86_64";
INSTALL_TARGET = "unknown-linux-gnu";
in
{
@MarcoPolo
MarcoPolo / lazyssh-config.hcl
Created Mar 7, 2021
lazyssh config for an on-demand ZFS backup target
View lazyssh-config.hcl
server {
listen = "0.0.0.0:7922" # The default
# Set this to the contents of lazyssh_host_key generated above.
host_key = <<-EOF
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
EOF
View main.tf
module "nixos_image_20_09" {
source = "../terraform-nixos/aws_image_nixos"
release = "20.09"
}
resource "aws_key_pair" "nix_key" {
key_name = "nix_key"
public_key = file("~/.ssh/aws_nix.pub")
}
View helloDie.ts
import { Dice } from 'https://deno.land/x/dodecasaurus/mod.ts';
import { Node } from 'https://deno.land/x/router/mod.ts'
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context
} from "https://deno.land/x/lambda/mod.ts";
const root = new Node();
@MarcoPolo
MarcoPolo / hello.ts
Created Jun 5, 2020
Hello World with Deno and Lambda
View hello.ts
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context
} from "https://deno.land/x/lambda/mod.ts";
export default async function (
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
@MarcoPolo
MarcoPolo / Dockerfile
Created May 14, 2020
Naive Docker file
View Dockerfile
FROM alpine:latest
WORKDIR /app
RUN apk add cargo
COPY . .
RUN cargo build --release
CMD ["/app/target/release/hello"]
@MarcoPolo
MarcoPolo / future_job_scheduler.rs
Created Apr 12, 2020
How to schedule Jobs in the future using as async/await and job_scheduler
View future_job_scheduler.rs
use async_std;
use futures_timer::Delay;
use job_scheduler::{Job, JobScheduler};
use std::time::Duration;
#[async_std::main]
async fn main() {
let a = async { 1u8 };
let b = a.await;
let mut sched = JobScheduler::new();
@MarcoPolo
MarcoPolo / RunKit.d.ts
Created Feb 18, 2020
Example of RunKit declaration file. These types may be out of date, so you probably want to copy the latest types from the docs directly.
View RunKit.d.ts
// Put this file alongside your JS code and VS Code will automatically pick it up!
interface Window {
RunKit: GlobalRunKit
}
type GlobalRunKit = {
createNotebook: (options: EmbedOptions) => NotebookEmbed
}
type EmbedOptions = {
View rnjsi.md

Interacting with Go from React Native through JSI

Introduction

There are 3 parts that let JS talk to Go:

  1. The C++ binding
  2. Installing the binding
  3. Calling Go