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 { FC } from "react"; | |
import { HttpError, apiErrorToStr, BlogDataService, Post } from "./api.service"; | |
import { useListPosts } from "./api.hooks"; | |
import { assertExhaustive } from "./utils"; | |
const ShowLoading: FC = () => ( | |
<div className="p-4 border border-blue-700 bg-blue-100">Loading...</div> | |
); | |
const ShowError: FC<{ error: HttpError }> = ({ error }) => ( |
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
{ | |
"devDependencies": { | |
"@svgr/rollup": "^4.3.3", | |
"@types/react": "^16.9.7", | |
"@types/react-dom": "^16.9.2", | |
"rollup": "^1.24.0", | |
"rollup-plugin-commonjs": "^10.1.0", | |
"rollup-plugin-filesize": "^6.2.1", | |
"rollup-plugin-node-resolve": "^5.2.0", | |
"rollup-plugin-terser": "^5.1.2", |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Merge Linked Lists"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.idemchenko.automaticbackups</string> | |
<key>StandardOutPath</key> | |
<string>/tmp/autoBackup.stdout</string> |
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
// ~/.config/fish/functions/gb.fish | |
function gb | |
set _curr_git_branch (git branch ^/dev/null | grep \* | sed 's/* //') | |
echo ">>> Rebasing $_curr_git_branch onto master <<<" | |
gco master | |
gpl | |
gpl origin master | |
gco $_curr_git_branch; |
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
const daggy = require('daggy'); | |
const Task = require('data.task'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const { sequence } = require('ramda'); | |
// type Entity | |
// = File String | |
// | Dir String (List Entity) | |
const Entity = daggy.taggedSum('Entity', { |
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
interface Functor<A> { | |
fmap<B>(f: (x: A) => B): Functor<B> | |
} | |
const fmap = <A, B>(f: (x: A) => B) => (fa: Functor<A>): Functor<B> => fa.fmap(f); | |
//=== String | |
interface String extends Functor<String> { | |
} |
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
/** | |
* Here are two essential functions for functional style in JavaScript. | |
* Unfortunately, functions are not curried by default in JS. | |
* Also, there is no function composition operator in JS. | |
* Thus, we have to implement these on our own. | |
**/ | |
const comp = (...fns) => (...args) => | |
fns.reduceRight((res, fn) => fn(...[].concat(res)), args); | |
const curryN = (num, fn) => (...args) => |
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
// just a helper | |
var $ = document.querySelector.bind(document); | |
// "show me the next image" button | |
var nextImage = Bacon.fromEvent($('#next'), 'click'); | |
// this button simulated "onload" event for the img tag | |
var img = Bacon.fromEvent($('#loaded'), 'click').map(_ => 'image.jpg.' + Math.random()); | |
// We need a stream that will be ended either on its own or by another stream. |
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
// This is the implmenetation of some of the lamdas from lamda calculus | |
// https://en.wikipedia.org/wiki/Lambda_calculus | |
console.clear(); | |
const log = function(x) { | |
console.log('log: ' + x); | |
return x; | |
} | |
// Boolean: |
NewerOlder