Skip to content

Instantly share code, notes, and snippets.

@fragamus
fragamus / gist:4d793df549a14fd9db9445562627a34b
Created March 8, 2018 06:53
Compiling neural's Data.FixedSize.Vector Couldn't match type ‘n + 1’ with ‘1 + n’
[12 of 22] Compiling Data.FixedSize.Vector ( src/Data/FixedSize/Vector.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Data/FixedSize/Vector.o )
/private/var/folders/rl/lpwgmdlj6ld9pljmv6_gj4hh0000gn/T/stack56339/neural-0.3.0.1/src/Data/FixedSize/Vector.hs:104:22: error:
• Couldn't match type ‘n + 1’ with ‘1 + n’
Expected type: Vector (n + 1) a
Actual type: Vector (1 + n) a
NB: ‘+’ is a type function, and may not be injective
• In the expression: Vector $ VS.cons x xs
In an equation for ‘cons’:
cons x (Vector xs) = Vector $ VS.cons x xs
@fragamus
fragamus / gist:83fee3f6408991284d21969005d6f862
Created April 7, 2018 22:05
source code for web page that I'm trying to automate with powershell
<title>Bizagi</title> <script type='text/javascript' src='jquery/bizagi.configuration.js'></script> <script type='text/javascript' src='jquery/steal.js'></script> <script type="text/javascript"> document.write("<script type='text/javascript' src='jquery/bizagi.loader.js?_=" + new Date().getTime() + "'>");</script> <script type="text/javascript" language="javascript"> // Redefine path to base var session = window.sessionStorage.getItem("bizagiAuthentication") || "{}"; var bizagiConcurrent; session = JSON.parse(session);
var BIZAGI_DEFAULT_CURRENCY_INFO = {
"symbol": session.symbol || "$",
"decimalSeparator": session.decimalSeparator || ",",
"groupSeparator": session.groupSeparator || ".",
"decimalDigits": session.decimalDigits || "2"
};
// Gets the loader instance, and load the module
var loader = bizagi.loader;
{ config, pkgs, ... }:
{
imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
ec2.hvm = true;
# Install some packages
environment.systemPackages =
with pkgs;
[
@fragamus
fragamus / gist:ec3499123867e96485a564ddc26442c4
Last active June 22, 2018 08:37
file exists but bash says it does not
$ ls -l /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
-rwxrwxrwx 1 2504 2504 79636 Mar 7 2002 /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
$ /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
bash: /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis: No such file or directory
I DISCOVERED THAT THE EXECUTABLE IS 32 BIT:
$ file /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
/root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.0, stripped
I need to patchelf this pre-built binary to run on my 64 bit intel nixos machine:
$ file foo
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.0, stripped
$ readelf -d foo
Dynamic section at offset 0x128f8 contains 21 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libm.so.6]
-- I want to make this code nice and crisp for teaching purposes
list_of_lists_of_tack_on_functions = (fmap (\x->(++[x]))) <$>
(["0","1","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]!!) <$>
(\x->(read [x])::Int) <$>
"4742836"
foldl (\list_of_names list_of_tack_on_functions -> list_of_tack_on_functions <*> list_of_names)
[""]
list_of_lists_of_tack_on_functions
@fragamus
fragamus / main.hs
Created September 13, 2018 05:04
deriving FromJSON and ToJSON for Literal
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
import Data.Aeson
import Data.Text
import Control.Applicative
@fragamus
fragamus / gist:9e472a78922c58b420bc164d06fa7645
Created September 13, 2018 23:58
So withSome just identifies the selector right
import Data.Some
asdf :: forall a. Maybe a -> Bool
asdf (Just _) = True
asdf Nothing = False
test1 = withSome (This (Just 5)) asdf
test2 = withSome (This Nothing) asdf
@fragamus
fragamus / some.hs
Last active September 19, 2018 04:47
Existential
{-# LANGUAGE GADTs #-}
import Data.Some
data ZeroOneTwo a where
Zero :: ZeroOneTwo ()
One :: Int -> ZeroOneTwo Int
Two :: (Int,Int) -> ZeroOneTwo Int
getSome :: Some ZeroOneTwo
git config --global user.name "Michael Gough"
git config --global user.email innovative.engineer@gmail.com
git init
git add .
git commit
curl -u 'fragamus' https://api.github.com/user/repos -d '{"name":"tokamak"}'
enter password