Skip to content

Instantly share code, notes, and snippets.

View MarcoPolo's full-sized avatar
🌠
Gradatim

Marco Munizaga MarcoPolo

🌠
Gradatim
View GitHub Profile
@MarcoPolo
MarcoPolo / css-colors
Created December 6, 2012 21:03
Convert hex color values to rgb clojure
(defn css-color [color]
(let [ colors (rest (clojure.string/split color #""))
red (take 2 colors)
green (take 2 (drop 2 colors))
blue (take 2 (drop 4 colors))]
(map #(-> (conj % "0x") (clojure.string/join) (read-string)) [red green blue])))
pkgs.stdenv.mkDerivation
{
name = "code-server";
src = pkgs.fetchurl
(
let
INSTALL_ARCH = "x86_64";
INSTALL_TARGET = "unknown-linux-gnu";
in
{
@MarcoPolo
MarcoPolo / bufchan.ts
Created November 11, 2022 15:28
A Go-like buffered channel for JS. Has backpressure
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> = []
@MarcoPolo
MarcoPolo / lazyssh-config.hcl
Created March 7, 2021 20:00
lazyssh config for an on-demand ZFS backup target
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
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")
}
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 June 5, 2020 20:15
Hello World with Deno and Lambda
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 19:58
Naive Docker file
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 April 12, 2020 04:07
How to schedule Jobs in the future using as async/await and job_scheduler
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 February 18, 2020 21:03
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.
// 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 = {