Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afcfc7bb07 | ||
|
|
4c8df0c5df | ||
|
|
58209a2c6e | ||
|
|
9d18db19a2 |
No files matched your search
+1
-1
@@ -111,7 +111,7 @@ article .header {
|
|||||||
|
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
body {
|
body {
|
||||||
width: 60rem;
|
width: 85rem;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-2
@@ -1,6 +1,18 @@
|
|||||||
/* Generated by pandoc. */
|
/* Generated by pandoc. */
|
||||||
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
|
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre.sourceCode
|
||||||
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
|
{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
/* border: 0; */
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
pre.sourceCode
|
||||||
|
{
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background-color: rgb(238,238,255);
|
||||||
|
padding: 10px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
|
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
|
||||||
td.sourceCode { padding-left: 5px; }
|
td.sourceCode { padding-left: 5px; }
|
||||||
.sourceCode span.kw { color: #007020; font-weight: bold; }
|
.sourceCode span.kw { color: #007020; font-weight: bold; }
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
var getApiIpfsCurrent = function(onSuccess, onError) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', '/api/ipfs/current', true);
|
||||||
|
xhr.setRequestHeader('Accept', 'application/json');
|
||||||
|
xhr.onreadystatechange = function () {
|
||||||
|
var res = null;
|
||||||
|
if (xhr.readyState === 4) {
|
||||||
|
if (xhr.status === 204 || xhr.status === 205) {
|
||||||
|
onSuccess();
|
||||||
|
} else if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
|
try { res = JSON.parse(xhr.responseText); } catch (e) { onError(e); }
|
||||||
|
if (res) onSuccess(res);
|
||||||
|
} else {
|
||||||
|
try { res = JSON.parse(xhr.responseText); } catch (e) { onError(e); }
|
||||||
|
if (res) onError(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(null);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
var success = function(x) {
|
||||||
|
$("#ipfs > em").html(x);
|
||||||
|
};
|
||||||
|
var error = function(x) {
|
||||||
|
$("#ipfs").hide();
|
||||||
|
console.log("ipfs hash not found: " + x);
|
||||||
|
};
|
||||||
|
getApiIpfsCurrent(success, error);
|
||||||
|
});
|
||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||||||
|
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)Line truncated
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"url": "https://github.com/NixOS/nixpkgs",
|
|
||||||
"rev": "7e1f60dfbba67b975d1a77d710a6f1437fd9709c",
|
|
||||||
"date": "2020-02-01T09:20:37-05:00",
|
|
||||||
"sha256": "0vk55459iljr5dzwnr5661l44b0wdc15952lk2rjcmxr1620yr5v",
|
|
||||||
"fetchSubmodules": false
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
title: Extensible configuration Pt. 1
|
||||||
|
date: 2019-03-27
|
||||||
|
---
|
||||||
|
|
||||||
|
This is the first part of a series where I'm going through how to make
|
||||||
|
extensible configuration. There is nothing groundbreaking or new in this
|
||||||
|
series, it's just me going through different implementations and trying to
|
||||||
|
understand them.
|
||||||
|
|
||||||
|
The source material for this post is [the fixed point implementation](https://github.com/NixOS/nixpkgs/blob/master/lib/fixed-points.nix) for nix.
|
||||||
|
|
||||||
|
By extensible configuration, I'm talking about nix style extensible
|
||||||
|
configuration, like overlays, overrides and extensions. Let's see an example of
|
||||||
|
an extensible configuration.
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
{ haskellPackages, fetchFromGitHub }:
|
||||||
|
|
||||||
|
let
|
||||||
|
purescript = fetchFromGitHub {
|
||||||
|
owner = "purescript";
|
||||||
|
repo = "purescript";
|
||||||
|
rev = "2cb4a6496052db726e099539be682b87585af494";
|
||||||
|
sha256 = "1v4gs08xnqgym6jj3drkzbic7ln3hfmflpbpij3qzwxsmqd2abr7";
|
||||||
|
}
|
||||||
|
hp = haskellPackages.extend (self: super: {
|
||||||
|
purescript = super.callCabal2nix "purescript" purescript {};
|
||||||
|
});
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
hp.purescript;
|
||||||
|
```
|
||||||
|
|
||||||
|
On a high level we are augmenting the `haskellPackages` attrset by replacing
|
||||||
|
the existing purescript package with a different one. The extension is a
|
||||||
|
function that takes two arguments, `self` and `super`. `super` is the original
|
||||||
|
non-lazy value and `self` is the lazy value that corresponds to the value at
|
||||||
|
end.
|
||||||
|
|
||||||
|
The first step on this journey is done by getting to know `fix`. Fix is
|
||||||
|
described being the least fixed point of a function. In practice it's a
|
||||||
|
function allowing declaring recursive functions without explicit recursion.
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
fix = f: let x = f x; in x
|
||||||
|
```
|
||||||
|
|
||||||
|
With fix you can have access to the lazy `self` value. It's value is whatever
|
||||||
|
would have been computed in the end. As it is lazy, it is possible to end up in
|
||||||
|
a recursive loop if there is a cyclic dependency.
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
let recursive = fix (self: {
|
||||||
|
foo = 3;
|
||||||
|
bar = self.foo + 1;
|
||||||
|
});
|
||||||
|
infinite = fix (self: {
|
||||||
|
foo = self.bar + 1;
|
||||||
|
bar = self.foo + 1;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
You can try those yourself. The first version is fine and returns an attrset
|
||||||
|
like you would expect. The second one has a cyclic dependency and nix helpfully
|
||||||
|
errors out.
|
||||||
|
|
||||||
|
The next step is making a function that has access to the unmodified original
|
||||||
|
values. This is managed through the `extends` function. It took a while for me to understand what's happening in there, but luckily nix has [good documentation](https://github.com/NixOS/nixpkgs/blob/67b1265fb3d38ead5a57fee838405a2d997777c2/lib/fixed-points.nix#L37-L65) for it.
|
||||||
|
|
||||||
|
``` nix
|
||||||
|
extends = f: rattrs: self: let super = rattrs self; in super // f self super
|
||||||
|
```
|
||||||
|
|
||||||
|
- https://elvishjerricco.github.io/2017/04/01/nix-style-configs-in-haskell.html
|
||||||
|
- https://github.com/NixOS/nixpkgs/blob/master/lib/fixed-points.nix
|
||||||
|
- https://chshersh.github.io/posts/2019-03-25-comonadic-builders
|
||||||
File renamed without changes.
+1
-10
@@ -1,13 +1,4 @@
|
|||||||
let
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
pin = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
|
|
||||||
pinnedPkgs = with pin; import (builtins.fetchTarball {
|
|
||||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
|
||||||
inherit sha256;
|
|
||||||
}) {};
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
{ pkgs ? pinnedPkgs }:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
haskellPackages = pkgs.haskellPackages;
|
haskellPackages = pkgs.haskellPackages;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
--------------------------------------------------------------------------------
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
import Data.Monoid (mappend)
|
import Data.List (sortOn)
|
||||||
|
import Data.Time (defaultTimeLocale, formatTime)
|
||||||
import Hakyll
|
import Hakyll
|
||||||
import Data.List (sortBy, sortOn)
|
|
||||||
import Data.Time (formatTime, defaultTimeLocale)
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@@ -31,34 +29,20 @@ main = hakyllWith defaultConfiguration{ deployCommand = "ipfs add -Q -r _site" }
|
|||||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
match "posts/incomplete/*" $ do
|
match "posts/*" $ do
|
||||||
route $ setExtension "html"
|
route $ setExtension "html"
|
||||||
compile $ pandocCompiler
|
compile $ pandocCompiler
|
||||||
>>= loadAndApplyTemplate "templates/post.html" postCtx
|
>>= loadAndApplyTemplate "templates/post.html" postCtx
|
||||||
>>= loadAndApplyTemplate "templates/default.html" postCtx
|
>>= loadAndApplyTemplate "templates/default.html" postCtx
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
match "posts/guides/*" $ do
|
create ["posts.html"] $ do
|
||||||
route $ setExtension "html"
|
|
||||||
compile $ pandocCompiler
|
|
||||||
>>= loadAndApplyTemplate "templates/post.html" postCtx
|
|
||||||
>>= loadAndApplyTemplate "templates/default.html" postCtx
|
|
||||||
>>= relativizeUrls
|
|
||||||
|
|
||||||
match "posts/brainstorming/*" $ do
|
|
||||||
route $ setExtension "html"
|
|
||||||
compile $ pandocCompiler
|
|
||||||
>>= loadAndApplyTemplate "templates/post.html" postCtx
|
|
||||||
>>= loadAndApplyTemplate "templates/default.html" postCtx
|
|
||||||
>>= relativizeUrls
|
|
||||||
|
|
||||||
create ["guides.html"] $ do
|
|
||||||
route idRoute
|
route idRoute
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- modFirst =<< loadAll "posts/guides/*"
|
posts <- modFirst =<< loadAll "posts/*"
|
||||||
let archiveCtx =
|
let archiveCtx =
|
||||||
listField "posts" postCtx (return posts) `mappend`
|
listField "posts" postCtx (return posts) <>
|
||||||
constField "title" "Guides" `mappend`
|
constField "title" "Posts" <>
|
||||||
defaultContext
|
defaultContext
|
||||||
|
|
||||||
makeItem ""
|
makeItem ""
|
||||||
@@ -78,8 +62,8 @@ modFirst = fmap reverse . modified
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
postCtx :: Context String
|
postCtx :: Context String
|
||||||
postCtx =
|
postCtx =
|
||||||
dateField "date" "%B %e, %Y" `mappend`
|
dateField "date" "%B %e, %Y" <>
|
||||||
modifiedField "modified" "%B %e, %Y" `mappend`
|
modifiedField "modified" "%B %e, %Y" <>
|
||||||
defaultContext
|
defaultContext
|
||||||
where
|
where
|
||||||
modifiedField key format = field key $ \i -> do
|
modifiedField key format = field key $ \i -> do
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<!-- Logo by Jason Long -->
|
<!-- Logo by Jason Long -->
|
||||||
<a href="https://git.rauhala.info"><img src="/images/git_16.png" alt="git" /></a>
|
<a href="https://git.rauhala.info"><img src="/images/git_16.png" alt="git" /></a>
|
||||||
<a href="/contact.html">Contact</a>
|
<a href="/contact.html">Contact</a>
|
||||||
|
<a href="/posts.html">Posts</a>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -29,6 +30,10 @@
|
|||||||
<footer>
|
<footer>
|
||||||
Site proudly generated by
|
Site proudly generated by
|
||||||
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
|
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
|
||||||
|
<span id="ipfs">and found on IPFS as <em></em></ipfs>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
<script type="application/javascript" src="/js/jquery-3.3.1.min.js"></script>
|
||||||
|
<script type="application/javascript" src="/js/api.js"></script>
|
||||||
|
<script type="application/javascript" src="/js/app.js"></script>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
A list of small and big guides.
|
Me writing out interesting ideas and experiments.
|
||||||
|
|
||||||
$partial("templates/post-list.html")$
|
$partial("templates/post-list.html")$
|
||||||
Reference in new issue
Block a user