Skip to content

Instantly share code, notes, and snippets.

View pkese's full-sized avatar

Peter Keše pkese

  • Viidea
  • Ljubljana
View GitHub Profile
See my DASH-IF presentation from October, 2014:
https://s3.amazonaws.com/misc.meltymedia/dash-if-reveal/index.html#/
1. encode multiple bitrates with keyframe alignment:
ffmpeg -i ~/Movies/5D2_Portrait.MOV -s 1280x720 -c:v libx264 -b:v 1450k -bf 2 \
-g 90 -sc_threshold 0 -c:a aac -strict experimental -b:a 96k -ar 32000 out.mp4
My input was 30 fps = 3000 ms. If it were 29.97, then a GOP size of 90 frames will yield a base segment
size of 3003 milliseconds. You can make the segment size some multiple of this, e.g.: 6006, 9009, 12012.

I have setup a table with custom id field as follows:

  app.use('session', new Service({
    Model: r,
    db,
    id: 'hash',
    name: 'sessions',
  }));
@pkese
pkese / BoolExpr.fs
Created June 14, 2019 08:53
BoolExpr eval in F#
type Expr =
| And of Expr * Expr
| Or of Expr * Expr
| Not of Expr
| Const of bool
let rec eval = function
| And (x,y) -> eval x && eval y
| Or (x,y) -> eval x || eval y
| Not x -> not (eval x)
@pkese
pkese / nixos.try.md
Last active July 25, 2020 23:44
My NixOS experience

My first steps with NixOS

Background:

  • I'd like to use NixOS to manage a 'container' with some services (e.g. Solr) on my headless server.
  • I'm currently running lxc, lxd and docker containers which is tech that I'm familiar with.
  • I'm assuming Nix can provide similar experience: presumably a pure λ(nix-config) -> reproducible container.

Ideally there'd be a short getting started tutorial. My familiarity is:

@pkese
pkese / adaptive_demo.fs
Last active August 13, 2020 19:45
FSharp.Data.Adaptive sample with React
module AdaptiveSample
open Fable.React
open Fable.React.Props
open FSharp.Data.Adaptive
let useAdaptive (v: aval<'T>) =
// initialize hook with initial value
let stateHook = Hooks.useState (AVal.force v)
let onChange () =
@pkese
pkese / fizzbuzz.fs
Last active February 1, 2021 10:45
let (|IsMultiple|_|) n x = if x % n = 0 then Some n else None
[1..100]
|> List.map (function
| IsMultiple 15 x -> "FizzBuzz"
| IsMultiple 5 x -> "Buzz"
| IsMultiple 3 x -> "Fizz"
| x -> $"{x}")
|> List.iter (printfn "%s")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pkese
pkese / PavedRoadsPerCapita.fsx
Created September 11, 2021 12:27
Join two tables from Wikipedia to render list of counties sorted by kilometres of paved roads per capita.
#!/usr/bin/dotnet fsi
#r "nuget: FSharp.Data, 4.2.2"
open FSharp.Data
open System
type RoadsHtml = HtmlProvider<"https://en.wikipedia.org/wiki/List_of_countries_by_road_network_size">
let roadsHtml = RoadsHtml.GetSample()
let roads =
@pkese
pkese / chart.js
Created October 24, 2021 11:05
Fetch vaccinations vs hospitalizations data from Our World In Data
<html>
<head>
<title>Covid vaccinations vs hospitalizations</title>
<script src="https://code.highcharts.com/highcharts.src.js"></script>
</head>
<body>
<figure class="highcharts-figure">
<div id="container" style="width:100%; height:100%;"></div>
</figure>
@pkese
pkese / episari65.fsx
Last active November 13, 2021 09:33
#!/usr/bin/env -S dotnet fsi /langversion:preview
// - Fetch EPISARI hospitalizations data from podatki.gov.si
// - Fetch vaccination data from api.sledilnik.org/api/vaccinations
// - Mix in static population demography data
// - Render hospitalizatized per 100k population json
#r "nuget: FSharp.Data, 4.2.5"
#r "nuget: FSharp.Json, 0.4.1"