Skip to content

Instantly share code, notes, and snippets.

View Javran's full-sized avatar

Javran Cheng Javran

View GitHub Profile
sorting-network> benchmarks
Running 1 benchmarks...
Benchmark bench: RUNNING...
benchmarking n = 4/random/Data.List.sort
time 490.8 μs (368.1 μs .. 606.9 μs)
0.508 R² (0.324 R² .. 0.669 R²)
mean 819.1 μs (622.0 μs .. 1.078 ms)
std dev 655.4 μs (441.1 μs .. 805.3 μs)
variance introduced by outliers: 99% (severely inflated)
Running 1 benchmarks...
Benchmark bench: RUNNING...
benchmarking n = 4/random/Data.List.sort
time 745.1 μs (448.1 μs .. 911.6 μs)
0.675 R² (0.548 R² .. 0.797 R²)
mean 727.2 μs (610.0 μs .. 883.7 μs)
std dev 466.7 μs (321.9 μs .. 664.0 μs)
variance introduced by outliers: 99% (severely inflated)
benchmarking n = 4/random/sortList4By
@Javran
Javran / Main.hs
Created August 26, 2022 05:21
Having some fun with https://hackage.haskell.org/package/typerep-map, can sorta carry around instances like this, caveat being keys have to be concrete ofc.
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.TypeRepMap as TM
import Data.Typeable
data Shower a = Sf (a -> String)
module Main (main) where
import CPython.Simple
main :: IO ()
main = initialize
@Javran
Javran / problem-diff.hs
Created February 26, 2021 09:58
Listing Exercism problems not yet ported to Haskell
#!/usr/bin/env stack
{- stack
script
--resolver lts-16.31
--package containers
--package http-client
--package http-client-tls
--package zip-archive
-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-top-binds #-}
module Lib
( main
)
where
import Control.Applicative
import java.lang.Exception
/*
Extra notes regarding Forth as expected by testcases:
- words are case-insensitive, this interpreter normalizes all symbols to uppercase.
- static scoping: when a word is being defined, the enviroment is kept as it is (i.e. closure required).
- the word itself is not considered in the definition of that word
(i.e. a previous definition of the same word may be picked)
- primitive words and operations are subject to shadowing.
{"268":{"asw":[{"max":0,"base":0},{"max":1,"base":0}],"los":[{"max":49,"base":14}],"evasion":[{"max":79,"base":39},{"max":80,"base":38}]},"455":{"asw":[{"max":59,"base":26},{"max":60,"base":26}],"los":[{"max":19,"base":6},{"max":20,"base":6},{"max":21,"base":6}],"evasion":[{"max":79,"base":44}]},"84":{"asw":[{"max":0,"base":0},{"max":1,"base":0},{"max":2,"base":0},{"max":3,"base":0}],"los":[{"max":69,"base":40},{"max":70,"base":40}],"evasion":[{"max":47,"base":27},{"max":48,"base":27},{"max":49,"base":27}]},"370":{"asw":[{"max":68,"base":18}],"los":[{"max":47,"base":9}],"evasion":[{"max":88,"base":50}]},"509":{"asw":[{"max":0,"base":0}],"los":[{"max":83,"base":45}],"evasion":[{"max":82,"base":41}]},"150":{"asw":[{"max":0,"base":0}],"los":[{"max":49,"base":16}],"evasion":[{"max":72,"base":36}]},"352":{"asw":[{"max":36,"base":12}],"los":[{"max":59,"base":18}],"evasion":[{"max":33,"base":10}]},"172":{"asw":[{"max":0,"base":0},{"max":1,"base":0}],"los":[{"max":52,"base":18},{"max":53,"base":16}],"evasion":[{"max"
render() {
const {ships} = this.props
const fakeRenderer = propName => props => (<div>{props[propName]}</div>)
return (
<div
style={{
flex: 1,
height: 0,
}}
>
@Javran
Javran / gen.js
Last active September 30, 2017 03:14
const fs = require('fs-extra')
const xs = fs.readJsonSync('raw.json')
const trBgm = id =>
id === 77 ? '艦娘音頭' :
id === 101 ? '月夜海' :
id === 102 ? '鎮守府秋刀魚祭り改二' :
`BGM_${id}`