Skip to content

Instantly share code, notes, and snippets.

View eduardonunesp's full-sized avatar
🐚

Eduardo Pereira eduardonunesp

🐚
View GitHub Profile
import fs from 'fs/promises'
import { create, load } from 'ipld-hashmap'
import { sha256 as blockHasher } from 'multiformats/hashes/sha2'
import * as blockCodec from '@ipld/dag-cbor' // encode blocks using the DAG-CBOR format
// A basic in-memory store for mapping CIDs to their encoded Uint8Array blocks
const store = {
map: new Map(),
get (k) { return store.map.get(k.toString()) },
put (k, v) { store.map.set(k.toString(), v) }
@eduardonunesp
eduardonunesp / hamt_test.go
Last active September 22, 2021 14:15
Basic HAMT (Hash array mapped trie) using golang module github.com/ipld/go-ipld-adl-hamt
package main
import (
"bytes"
"fmt"
"io"
"github.com/davecgh/go-spew/spew"
"github.com/ipfs/go-cid"
hamt "github.com/ipld/go-ipld-adl-hamt"
@eduardonunesp
eduardonunesp / battle_grid_skel.c
Created April 30, 2021 15:48
Basic Skeleton for Shinning Force like game
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define GRID_SIZE 384
#define GRID_WIDTH 16
#define MAX_PAWNS_IN_GAME 50
typedef struct pawn_s {
@eduardonunesp
eduardonunesp / flatten_matrix.c
Created April 29, 2021 21:30
Flatten 2D Matrix
#include <stdio.h>
#include <stdlib.h>
#define BOARD_SIZE 64
typedef enum {
COOL = 1 << 0,
GREAT = 1 << 1,
} op_type_e;

Keybase proof

I hereby claim:

  • I am eduardonunesp on github.
  • I am eduardonunesp (https://keybase.io/eduardonunesp) on keybase.
  • I have a public key whose fingerprint is E672 12E6 1060 2345 3A72 6F98 8A07 DEF0 258F 7829

To claim this, I am signing this object:

@eduardonunesp
eduardonunesp / exporter.rs
Created January 11, 2021 18:31
pdf-exporter
use std::fs::File;
use std::io::{prelude::*, BufReader, Write};
use std::process::Command;
use actix_multipart::Multipart;
use actix_web::{
get, http::StatusCode, post, web, App, Error, HttpResponse, HttpServer, Responder,
};
use futures::{StreamExt, TryStreamExt};
use tempdir::TempDir;
@eduardonunesp
eduardonunesp / main.h
Created November 23, 2020 16:56
Tetris
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <SDL2/SDL.h>
#include "pieces.h"
#ifdef _DEBUG
#define LOG(msg) printf(msg);
#define LOGF(fmt, ...) fprintf(stdout, fmt, __VA_ARGS__)
@eduardonunesp
eduardonunesp / snake.c
Last active November 21, 2020 18:22
Snake Game
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <SDL2/SDL.h>
#ifdef _DEBUG
#define LOG(msg) printf(msg);
#define LOGF(fmt, ...) fprintf(stdout, fmt, __VA_ARGS__)
#else
@eduardonunesp
eduardonunesp / fakes3.test.js
Created June 30, 2020 12:43
Using Node.js AWS-SDK + FakeS3 mocking tests
const fs = require('fs')
const AWS = require('aws-sdk')
const FAKE_S3_HOST = process.env.FAKE_S3_HOST || "localhost"
const FAKE_S3_PORT = process.env.FAKE_S3_HOST || "localhost"
// Create S3 service object using fakes3
const s3 = new AWS.S3({
region: 'us-east-2',
secretAccessKey: '123',
@eduardonunesp
eduardonunesp / main.cpp
Last active May 15, 2020 23:09
Vector2 template with useful functions for geometry
#include <iostream>
#include "Vector2.h"
int main(int argc, const char * argv[]) {
Vector2<float> u {-8, 1};
Vector2<float> v {-2, 7};
std::cout << "Anglen (degrees): " << u.angle(v) * (180/M_PI) << std::endl;
return 0;
}