Skip to content

Instantly share code, notes, and snippets.

@menduz
menduz / game.ts
Last active Feb 3, 2021
loading kernel modules from Decentraland's SDK scene
View game.ts
executeTask(async () => {
const module = await dcl.loadModule('@decentraland/CommunicationsController')
const rpcResult = await dcl.callRpc(module.rpcHandle, 'send' /* remote method */, [message /* argument list */])
/**
The code avobe is the same as:
import {send} from "@decentraland/CommunicationsController"
@menduz
menduz / readme.md
Last active Jan 22, 2021
Unified NFT naming for blockchain based Metaverses
View readme.md

!! Migrated to https://github.com/common-metaverse/urn-namespaces !!


A common way to refer to assets across the metaverse projects

Identifying a blockchain asset is difficult. Wallets, exchanges, tools and other pieces of software need to know the specifics about how to interact with the project's infrastructure to get images or to render content. This proposal shows a temptative solution to the content addressing mechanisms to embed our crypto-art, assets, wearables and avatars into metaverse(s).

URN

View index.sh
# install dependencies
brew install pam_yubico
if sc_auth identities | grep PIV --quiet
then
# run lock with sudo
sudo bash ./lockpan-1.sh
else
@menduz
menduz / url-parser.ts
Last active Jan 5, 2021
url-parser-types.ts
View url-parser.ts
/**
* Creates object types compliant with https://github.com/pillarjs/path-to-regexp
*
* ParseUrlParams<"/users/:user_id/:test+"> = { user_id: string, test: string | string[] }
*
* @public
*/
export type ParseUrlParams<State extends string, Memo extends Record<string, any> = {}> = string extends State
? ParseUrlParams.ParserError<"ParseUrlParams got generic string type">
: State extends `${infer _}:${infer Rest}`
@menduz
menduz / db.ts
Created Nov 25, 2020
database ts
View db.ts
import { Pool, PoolClient, QueryResult } from "pg";
import config = require("../config");
import sql = require("sql-template-strings");
if (!config.db) throw new Error("Cannot load config.db");
export const pool = new Pool(config.db);
export async function getClient<T>(
@menduz
menduz / dcl.md
Created Nov 24, 2020
How to implement your own Decentraland, quick and dirty
View dcl.md

Runtime

Decentraland run scenes inside a WebWorker, in an ES5 context including Fetch + WebSockets + dcl object.

Every generated scene should run by itself. That is, a piece of code that can be evaluated by an eval in a proper context. You can compile scenes using Webpack, esbuild, or the Decentraland CLI.

The scenes will interact with the renderer using the dcl object.

dcl object

@menduz
menduz / dataview-polyfill.js
Created Oct 6, 2020 — forked from tjmehta/dataview-polyfill.js
DataView (and ArrayBuffer) polyfill that works in any engine (including old IE).
View dataview-polyfill.js
void function(global){
if ('DataView' in global && 'ArrayBuffer' in global) {
return;
}
var hide = (function(){
// check if we're in ES5
if (typeof Object.getOwnPropertyNames === 'function' && !('prototype' in Object.getOwnPropertyNames)) {
var hidden = { enumerable: false };
View scriptsystem.cpp
#include <eternity.hpp>
ScriptSystem::ScriptSystem() {
m_platform = 0;
m_isolate = 0;
m_scriptableCount = 0;
m_scriptablePoolSize = 0;
m_scriptables = 0;
}
View script.cpp
Script::Script() {
}
Script::~Script() {
}
void Script::Initialize(char* src) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
View mental-models.md
  • Confirmation bias: a pattern that causes one to notice or look for things that confirm one's beliefs rather that counter-evidence.

  • Loss aversion: Loss aversion refers to people's tendency to prefer avoiding losses to acquiring equivalent gains: it is better to not lose $5 than to find $5. The principle is very prominent in the domain of economics. What distinguishes loss aversion from risk aversion is that the utility of a monetary payoff depends on what was previously experienced or was expected to happen. Some studies have suggested that losses are twice as powerful, psychologically, as gains.

  • Intuition:  Personal experience coded into your personal neural network, which means your