Skip to content

Instantly share code, notes, and snippets.

Avatar

Marco Munizaga MarcoPolo

View GitHub Profile
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
@MarcoPolo
MarcoPolo / prop-enumerations.js
Created Feb 11, 2019
Enumerate through props quickly
View prop-enumerations.js
function seedPossibilitiesCount(seed) {
if (Array.isArray(seed)) {
return seed.length
} else if (typeof seed === 'object' && !!seed && seed.constructor === Object) {
let count = 1
Object.keys(seed).forEach(k => {
count *= seedPossibilitiesCount(seed[k])
})
return count
}
View helper-server.js
var http = require('http')
var fs = require('fs')
var server = http.createServer(function(request, response) {
var req = request
response.writeHead(200, {'Content-Type': 'textplain'})
if (req.method === 'POST') {
var body = ''
req.on('data', function(data) {
body += data
})
@MarcoPolo
MarcoPolo / gist:db5ffb4ca5f14d42d5f242a6af0b2524
Last active Nov 10, 2016
Traverse inverse dependency react native
View gist:db5ffb4ca5f14d42d5f242a6af0b2524
counts = {}
a = {} // your inverse dep map
// helper to return a string of n spaces... omg this is left pad
function s (n) { let k = ''; for (i = 0; i<n; i++) {k = k + ' '}; return k}
function f (k, ttl, indent, seen) {
if (seen[k]) { console.warn('circular dep found', k, seen) }
let kl = (''+k).length; counts[k] = (counts[k] || 0) + 1 ;return (ttl > 0 && a[k] && a[k].length ? k + ' -> ' + a[k].map(i => f(i, ttl - 1, indent + s(4+kl), Object.assign(seen, {[k]: true}))).join('\n' + s(kl + 4) + indent) : k)
}
You can’t perform that action at this time.