Skip to content

Instantly share code, notes, and snippets.

View barthap's full-sized avatar
Unavailable. Not responding to issues.

Bartłomiej Klocek barthap

Unavailable. Not responding to issues.
View GitHub Profile
@barthap
barthap / references.sql
Created September 26, 2018 13:36
SQL schema to create some together-referenced entities
create table Type (
TypeCode CHAR(1) NOT NULL,
Name CHAR(30) NOT NULL,
CONSTRAINT Type_PK PRIMARY KEY (TypeCode),
CONSTRAINT Type_AK UNIQUE (Name)
);
create table Items (
ItemId int not null,
TypeCode CHAR(1) not null,
@barthap
barthap / SimplestStack.cpp
Last active January 27, 2019 12:19
Simplest pointer-based C++ stack definition
#include <iostream>
#include <stdexcept>
template <typename T>
class Stack
{
public:
void push(T elem)
{
auto n = new Node;
@barthap
barthap / dangling_references.cpp
Last active January 22, 2019 14:53
(PL) Modern C++: Move semantic and dangling reference example
#include <utility>
#include <memory>
#include <iostream>
#include <vector>
#include <stdexcept>
class Obiekt
{
std::unique_ptr<std::string> nazwa; //celowo unique_ptr a nie zwykły string
//aby zademonstrować działanie
@barthap
barthap / list_remove_if.cpp
Last active January 22, 2019 15:08
Testing std::list::remove_if() for memory organisation
//
// Created by Barthap on 2019-01-22.
//
#include <utility>
#include <iostream>
#include <vector>
#include <list>
int main()
@barthap
barthap / PiMonteCarlo.py
Created January 27, 2019 12:18
Monte Carlo PI approximation visualisation using Python and PyGame
import math
import random
import sys
import pygame
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
@barthap
barthap / Kotlin-functions.md
Last active August 10, 2020 18:10
Kotlin and its cool functions

Creating custom universal native modules for your Expo bare workflow apps - Part 1

TODO: Make an awesome introduction. The one below is a draft

You love Expo. But sometimes you have to add some native code. With Expo Unimodules you can make your custom native code reusable between any Expo app, and with a little more effort, between any React Native app. What's more - the native code will be loaded automatically when you do yarn install, without the need of any additional linking. And in this article I'll show you how to.

I assume you are using Mac - however it's not necessary unless you follow the iOS part. Also, some terminal commands I use are Mac-specific.

What are unimodules?

@barthap
barthap / Tabs.md
Created September 22, 2020 08:45
Tabs component in React, works in mdx-js

Demo

tabs1

tabs2


Usage:

@barthap
barthap / Readme.md
Created October 28, 2020 10:03
Simple TypeScript GraphQL query builder

A simple GraphQL Query Builder experiment.

graphql folder structure

  • __tests__
  • queries - Domain specific Query API, e.g. UserQuery
  • mutations - Same as above, but mutations.
  • types - TypeScript interfaces directly corresponding to GQL schema types, e.g. User. Can be generated typedefs also
  • GraphqlClient.ts - GraphQL client + error handling. Can be any client, I use @urlq/core here.
  • QueryBuilder.ts - Query Builder implementation and some TypeScript magic
@barthap
barthap / __mocks__--fs--promises.js
Last active February 25, 2023 23:20
Mocking filesystem in Node.js with `memfs`
// __mocks__/fs/promises.js
const { fs } = require("memfs");
module.exports = fs.promises;