Skip to content

Instantly share code, notes, and snippets.

View barinbritva's full-sized avatar
🏴‍☠️
Karibu!

barinbritva

🏴‍☠️
Karibu!
View GitHub Profile
@barinbritva
barinbritva / flappy-article.md
Last active February 7, 2024 08:11
flappy bird article

TON blockchain for games

What’s in the tutorial

In this tutorial we will consider how to add TON blockchain to a game. For our example we will use a Flappy Bird clone written in Phaser and will add GameFi features step by step. In the tutorial we will use short code pieces and pseudocode to make it more readable. Also, we will provide links to real code blocks to help you understand better. The whole implementation can be found in the demo repo.

Flappy Bird game without GameFi features

We are going to implement the following:

  • Achievements. Let’s reward our users with SBTs. Achievement system is a great tool to increase user engagement.
  • Game currency. In TON blockchain it’s easy to launch your own token (jetton). The token can be used to create an in-game economy. Our users will be able to earn the game coins to spend them later.
@barinbritva
barinbritva / objectEntries.ts
Created March 13, 2023 12:24
typesafe objectEntries
// https://stackoverflow.com/a/74891854/3359277
export function typeSafeObjectEntries<
T extends { [key: string | number | symbol]: unknown },
K extends keyof T,
V extends T[K]
>(o: T) {
return Object.entries(o) as unknown as [K, V][];
}
@barinbritva
barinbritva / admin-dependency.ts
Last active February 2, 2022 12:05
Firebase example
import {container} from 'tsyringe';
import admin, {type ServiceAccount, type app} from 'firebase-admin';
import {type Firestore} from 'firebase-admin/firestore';
import serviceAccount from '../../serviceAccountKey.json';
export function buildDependencyContainer(): void {
const firebaseApp = admin.initializeApp({
credential: admin.credential.cert(serviceAccount as ServiceAccount)
});
container.register<app.App>('firebaseApp', {
@barinbritva
barinbritva / 1-jsunderhood-week
Last active August 25, 2022 06:27
jsunderhood-week
// Gist name placeholder

Ссылки

Основное

Мой материал

@barinbritva
barinbritva / use-system-font.css
Created September 20, 2020 15:26
Use system font in each OS.
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
@barinbritva
barinbritva / frontend-live-2020.md
Last active December 12, 2021 14:47
Список ссылок с доклада "TypeScript как фундамент архитектуры приложения" FrontendLive 2020

Ссылки

Рефакторинг

Refactoring.Guru - всё про рефакторинг: что такое рефакторинг, как понять, что настало время проводить рефакторинг, как его проводить, паттерны проектирования с примерами на многих языках, включая TypeScript.

Разворачивание проекта на TypeScript

  • init-typescript-app - мой пакет для разворачивания проектов, на котором был создан проект для презентации. Возможность выбирать "строгость" TypeScript для новичков или опытных, публикация вашего пакета в NPM.
  • TSDX - разворачивание TypeScript проекта, prettier, rollup, eslint
  • oclif и Gluegun - разворачивание TypeScript для создания CLI утилит
  • Nest TypeScript Starter - официальный темплейт для создания бекенд-приложений на NestJS
@barinbritva
barinbritva / react-handle-click-outside.ts
Last active August 10, 2020 13:26
React detect clicked element
protected componentWillMount(): void {
document.addEventListener('click', this.toggle);
}
protected componentWillUnmount(): void {
document.removeEventListener('click', this.toggle);
}
private toggle = (event): void => {
event.preventDefault();