- Create your realm / client
- Inside client configuration go to "Mappers"
- Click on "Create"
- Name it "hasura"
- Choose Mapper Type "Script Mapper"
- Add following script to demonstrate how it works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BitBuilder, BitReader, Cell, beginCell } from "@ton/ton"; | |
const OFFCHAIN_CONTENT_PREFIX = 0x01; | |
export function encodeOffChainContent(content: string) { | |
let data = Buffer.from(content); | |
let offChainPrefix = Buffer.from([OFFCHAIN_CONTENT_PREFIX]); | |
data = Buffer.concat([offChainPrefix, data]); | |
return makeSnakeCell(data); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCloudStorage } from "@tma.js/sdk-react" | |
import { useEffect, useState } from "react" | |
type OP = 'addItem' | 'getAll' | 'purge' | |
const createKeys = (length: number, idxKey: Function): string[] => Array.from({ length: length }).map((_, idx: number) => idxKey(idx)) | |
export const useCloudDB = (tableName: string, threshold: number) => { | |
const cs = useCloudStorage() | |
const [busy, setBusy] = useState(false) | |
const [threshReached, setThreshReached] = useState(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import uasyncio as asyncio | |
class Store: | |
is_loading = False | |
is_saving_scheduled = False | |
data = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uasyncio as asyncio | |
from machine import ADC | |
import time | |
class Levels: | |
_last_level = None | |
debounce_ms = 200 | |
none_level = 65000 | |
callbacks = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react" | |
import { useQuery } from "blitz" | |
const useLazyQuery = (resolver, inputArg, options = {}) => { | |
const [enabled, setEnabled] = useState(false) | |
const [result, extras] = useQuery(resolver, inputArg, { | |
...options, | |
enabled, | |
suspense: false, | |
onSettled: () => setEnabled(false), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class MailgunClient { | |
apiKey: string; | |
domain: string; | |
defaults?: { | |
from?: string; | |
subject?: string; | |
}; | |
constructor(apiKey: string, domain: string, defaults?: Record<string, any>) { | |
this.apiKey = apiKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Karta.Web.ReactPlug do | |
import Plug.Conn | |
def init(options), do: options | |
def call(conn, _opts) do | |
conn | |
|> put_resp_header("content-type", "text/html; charset=utf-8") | |
|> Plug.Conn.send_file(200, Application.app_dir(:karta_web, "priv/static/index.html")) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires Erlang/OTP 19.0. Invoke as: | |
# | |
# iex --erl "-proto_dist Elixir.Epmdless -start_epmd false -epmd_module Elixir.Epmdless_epmd_client" --name frobozz3 | |
# A module containing the function that determines the port number | |
# based on a node name. | |
defmodule Epmdless do | |
def dist_port(name) when is_atom(name) do | |
dist_port Atom.to_string name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.5 | |
ARG APP | |
EXPOSE 5000 | |
EXPOSE 4369 | |
ENV PORT=5000 \ | |
MIX_ENV=prod | |
RUN apk --no-cache add ncurses openssl |
NewerOlder