Skip to content

Instantly share code, notes, and snippets.

View g0xA52A2A's full-sized avatar

George Brown g0xA52A2A

View GitHub Profile
@osdf
osdf / test_numpy.py
Created October 5, 2012 21:27
Testing numpy and scipy setups
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
@Icelandjack
Icelandjack / SystemF.hs
Last active November 27, 2018 02:00
System F
-- SYSTEM F
-- http://homepages.inf.ed.ac.uk/slindley/papers/embedding-f.pdf
--
-- Type-level lambdas
-- https://gist.github.com/AndrasKovacs/ac71371d0ca6e0995541e42cd3a3b0cf
{-# language TemplateHaskell, ScopedTypeVariables, RankNTypes,
TypeFamilies, UndecidableInstances, DeriveFunctor, GADTs,
TypeOperators, TypeApplications, AllowAmbiguousTypes,
@infogulch
infogulch / utf8.cpp
Created December 6, 2018 03:49
UTF-8 Decoder in Mill assembly
// decode accepts a byte and a vector of the next 3 bytes (the %first byte and the possible
// %continuation bytes and returns a decoded code point in an integer, and the number of bytes
// consumed (including the first byte) The vector may contain NaR bytes if at the end of a buffer
F('decode') %first, %cont;
// fast path for 1 byte
con(v(0xe0, 0xf0, 0xf8)) %prefmask, //R0 # masks of the three possible prefixes
lssu(%first, 0x80) %onebyte, // E0 # check if the first byte is < 0x80
andlu(%first, %prefmask) %masked, // E1 # bit-and with bitmasks of 3 possible prefixes
retntr(%onebyte, %first, 1); // F0# if < 0x80 return the first byte & consume one byte
@AndrasKovacs
AndrasKovacs / TypeLambdas.hs
Last active September 23, 2019 14:48
Type lambdas and induction with GHC 8.4.2 and singletons
{-# language TemplateHaskell, ScopedTypeVariables, RankNTypes,
TypeFamilies, UndecidableInstances, DeriveFunctor, GADTs,
TypeOperators, TypeApplications, AllowAmbiguousTypes,
TypeInType, StandaloneDeriving #-}
import Data.Singletons.TH -- singletons 2.4.1
import Data.Kind
-- some standard stuff for later examples' sake
colorscheme apprentice
highlight Type ctermfg=103
highlight cssClassName ctermfg=6
highlight cssClassNameDot ctermfg=6
highlight link jsFuncCall Type
highlight cssBraces ctermfg=fg
highlight htmlLink ctermfg=fg
highlight Function ctermfg=182
highlight MatchParen ctermfg=182 ctermbg=232
highlight Constant ctermfg=210
@lithdew
lithdew / sparse.zig
Created June 26, 2022 09:26
zig: generational paged sparse set
const std = @import("std");
const sparse = @This();
/// This is an implementation of a paged sparse set that stores the payload in
/// the sparse array.
//
/// A sparse set has a dense and a sparse array. The sparse array is directly
/// indexed by a 64 bit identifier. The sparse element is linked with a dense
/// element, which allows for liveliness checking. The liveliness check itself
@BoltsJ
BoltsJ / qfsign.vim
Last active December 5, 2022 06:30
Automatically place signs based on the quickfix list.
if exists('g:loaded_qfsign')
finish
endif
let g:loaded_qfsign=1
sign define QFErr texthl=QFErrMarker text=E
sign define QFWarn texthl=QFWarnMarker text=W
sign define QFInfo texthl=QFInfoMarker text=I
augroup qfsign
@luc-tielen
luc-tielen / Bad.hs
Created June 16, 2019 11:41
MultiRec in combination with "Trees That Grow" approach
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Bad where
import Prelude
import Data.Kind ( Type )
import Generics.MultiRec.TH

Listpack specification

Version 1.0, 1 Feb 2017: Intial specification.

Version 1.1, 2 Feb 2017: Integer encoding simplified. Appendix A added.

Version 1.2, 3 Feb 2017: Better specify the meaning of the num-elements
                         field with value of 65535. The two 12 bits

positive/negative integers encodings were

@yangzhixuan
yangzhixuan / HiParser.hs
Created September 13, 2020 15:03
Higher order parser combinator langauge
{-# LANGUAGE GADTs, TypeFamilies, DataKinds, TypeOperators, RankNTypes, PolyKinds #-}
module HiParser where
import Control.Monad.Trans.State.Lazy
import GHC.Types
-- All types of the parser language:
-- BaseTy: every Haskell type is a base type of the parser language
-- Arrow: function types of the parser language
data Tys = BaseTy GHC.Types.Type | Arrow Tys Tys