Skip to content

Instantly share code, notes, and snippets.

View coleea's full-sized avatar
💭
I may be slow to respond.

Mario KB coleea

💭
I may be slow to respond.
View GitHub Profile
@nicolashery
nicolashery / rxjs-react.js
Last active August 1, 2022 03:36
Fetching data asynchronously with RxJS and React
import React from 'react';
import _ from 'lodash';
import Rx from 'rx';
import superagent from 'superagent';
let api = {
host: 'http//localhost:3001',
getData(query, cb) {
superagent
@JPGygax68
JPGygax68 / consume-ffmpeg-libs.cmake
Last active November 23, 2024 15:21
#CMake: how to add the #FFmpeg libraries to a target
# Detect architecture
if (CMAKE_SIZEOF_VOID_P MATCHES 8)
set( PROJECT_ARCH "x86_64" )
else(CMAKE_SIZEOF_VOID_P MATCHES 8)
set( PROJECT_ARCH "x86" )
endif(CMAKE_SIZEOF_VOID_P MATCHES 8)
# FFmpeg
@DrBoolean
DrBoolean / free-er.js
Last active March 17, 2024 10:33
Free(er) monads in JS (pt 1)
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
const kleisli_comp = (f, g) => x => f(x).chain(g)
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@gcanti
gcanti / fp-ts-technical-overview.md
Last active March 11, 2024 02:40
fp-ts technical overview

Technical overview

A basic Option type

// Option.ts

// definition
export class None {
  readonly tag: 'None' = 'None'
@UndoneKittens
UndoneKittens / eamuse_djdata_score_parser.js
Last active July 11, 2018 09:56 — forked from McMaNGOS/eamuse_djdata_score_parser.js
eAmusement beatmania IIDX DJ DATA scores -> JSON
/* Cheerio-powered parser for the DJ DATA score page on the beatmania IIDX website.
Requires 'cheerio', 'request', and 'iconv' packages.
Needs 'Cookie' header from manual login for authentication.
Results in an array of JSON-formatted scores, which looks like this:
{
"songs": [{
"song": {
"name": "SONG NAME",
@raveclassic
raveclassic / form.ts
Created September 26, 2019 15:34
form test
import { OutputOf, string, type, Type, TypeOf, Validation } from 'io-ts';
import React, { FC, useState } from 'react';
import { either, left, map, right } from 'fp-ts/lib/Either';
import { sequenceS } from 'fp-ts/lib/Apply';
import { NumberFromString } from 'io-ts-types/lib/NumberFromString';
import { pipe } from 'fp-ts/lib/pipeable';
const formDataCodec = type({
age: NumberFromString,
password: string,
@nktknshn
nktknshn / schema_to_types.ts
Last active August 6, 2022 15:26
Generate io-ts codecs and types for JSON data from a set of samples using jq, quicktype and io-ts-codegen
/*
Generate io-ts codecs and types for JSON data from a set of samples using jq, quicktype and io-ts-codegen
Usage:
# collect samples
for i in $(seq 1 10); do
wget -P samples/ https://api.github.com/events && sleep 2
done
@gragland
gragland / use-async.jsx
Last active February 17, 2024 16:42
React Hook recipe from https://usehooks.com
import React, { useState, useEffect, useCallback } from 'react';
// Usage
function App() {
const { execute, status, value, error } = useAsync(myFunction, false);
return (
<div>
{status === 'idle' && <div>Start your journey by clicking a button</div>}
{status === 'success' && <div>{value}</div>}
@atacratic
atacratic / ability-tutorial.output.md
Last active October 22, 2024 20:55
Unison abilities - unofficial alternative tutorial

This tutorial explains how Unison handles 'effectful' computations, like storing state or performing I/O, using abilities. It assumes you haven't come across abilities before, and covers everything from the ground up.

This is an unofficial tutorial, written before the one on unisonweb.org/docs. The approach taken here is slow and methodical. Your first stop should be the official tutorial, if you haven't seen it already.

This doc is a Unison transcript - the source is here.

Terminology note: other languages with ability systems typically call them 'effect handlers' or 'algebraic effects', but many of the ideas are the same.

Introducing abilities

@jjcodes78
jjcodes78 / nextjs-deploy.md
Last active June 4, 2025 08:59
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw