Skip to content

Instantly share code, notes, and snippets.

View Mati365's full-sized avatar
🚧
Work Work Work

Mateusz Bagiński Mati365

🚧
Work Work Work
View GitHub Profile
@reecelucas
reecelucas / useScrollBlock.js
Last active December 17, 2024 13:11
React hook to enable/disable page scroll
import { useRef } from 'react';
const safeDocument = typeof document !== 'undefined' ? document : {};
/**
* Usage:
* const [blockScroll, allowScroll] = useScrollBlock();
*/
export default () => {
const scrollBlocked = useRef();
@mtesseract
mtesseract / deploying-reflex-nixos.md
Last active October 5, 2023 21:25
Deploying a Reflex Application to NixOS

Deploying a Reflex Application to NixOS

In the following post I describe how a simple Haskell web application built on top of Reflex FRP can be deployed to a remote NixOS server. If a remote NixOS server is available using it for deployment can be cheaper alternative to commercial cloud providers in case the features of those (e.g. scaling, hosted services, availability guarantees, etc.) are not strictly required.

The sample Reflex application can be found on GitHub.

Our setting is as follows:

  • The application, consisting of a frontend and a backend, is built with Nix
  • The development system is a Mac (i.e., not x86_64-linux)
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 20, 2025 20:49
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@nodew
nodew / monad.ts
Last active October 22, 2023 10:35
monad with typescript
interface Functor<A> {
fmap<B>(fn: (a: A) => B): Functor<B>
}
abstract class Applicative<A> implements Functor<A> {
static of: <A>(a: A) => Applicative<A>;
abstract fmap<B>(fn: (a: A) => B): Applicative<B>;
abstract ap<B, C>(this: Applicative<(b: B) => C>, ma: Applicative<B>): Applicative<C>;
lift<B, C>(fn: (a: A, b: B) => C) : (mb: Applicative<B>) => Applicative<C> {
@tulik
tulik / tic-tac-toe.sql
Created October 2, 2018 16:23
TicTacToe in SQL (Postgres)
--- Introduced by Mariusz Krynski.
with recursive rnd_move(move) as (
select *, random() rnd from generate_series(1, 9) move
), winning_positions(a, b, c) as (
values (1, 2, 3), (4, 5, 6), (7, 8, 9), -- rows
(1, 4, 7), (2, 5, 8), (3, 6, 9), -- cols
(1, 5, 9), (3, 5, 7) -- diagonals
), game as (
select 'O' as who_next, ARRAY['.', '.', '.', '.', '.', '.', '.', '.', '.'] as board
@gitCommitLit
gitCommitLit / index.html
Created September 24, 2018 13:04
Liquid Button
<!-- For more examples: https://codepen.io/Zaku/pen/eRmRxz -->
<svg class="liquid-button"
data-text="BUTTON"
data-force-factor="0.1"
data-layer-1-viscosity="0.5"
data-layer-2-viscosity="0.4"
data-layer-1-mouse-force="400"
data-layer-2-mouse-force="500"
data-layer-1-force-limit="1"
@cyril-lakech
cyril-lakech / morgan.nestjs.middleware.ts
Created August 30, 2018 16:14
Simplest Morgan NestJS Middleware
import { Injectable, MiddlewareFunction, NestMiddleware } from '@nestjs/common';
import * as morgan from 'morgan';
import { LoggerService } from './mylogger';
@Injectable()
export class MorganMiddleware implements NestMiddleware {
constructor(private readonly logger: LoggerService) {}
resolve(): MiddlewareFunction {
return morgan('combined', {
stream: { write: str => this.logger.info(str) },
@jaytaylor
jaytaylor / delete-from-v2-docker-registry.md
Last active February 11, 2025 15:28
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@Manouchehri
Manouchehri / ieee754.js
Created October 13, 2017 19:00 — forked from bartaz/gist:1119041
Convert JavaScript number to string of 64bit double precision floating point representation (IEEE 754)
// Convert a JavaScript number to IEEE-754 Double Precision
// value represented as an array of 8 bytes (octets)
//
// http://cautionsingularityahead.blogspot.com/2010/04/javascript-and-ieee754-redux.html
function toIEEE754(v, ebits, fbits) {
var bias = (1 << (ebits - 1)) - 1;
// Compute sign, exponent, fraction