Skip to content

Instantly share code, notes, and snippets.

View vaibhavsagar's full-sized avatar
🕺
🪩

Vaibhav Sagar vaibhavsagar

🕺
🪩
View GitHub Profile
@vaibhavsagar
vaibhavsagar / Dockerfile
Created June 24, 2024 00:54
Small GHC Dockerfile for container2wasm
FROM debian:buster-slim
ENV LANG C.UTF-8
# haskell dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# ca-certificates \
curl \
# dpkg-dev \
@vaibhavsagar
vaibhavsagar / default.nix
Created June 15, 2019 15:28
A `default.nix` for Semantic
let
nixpkgs-src = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/archive/f197f57bd336746b53e5f1668ac7df1b63da7c9f.tar.gz";
sha256 = "0cj4h39fhrm0nzxgfcjxy457zhi2rajpgm6abas816srmr4bb6nn";
};
semantic-src = builtins.fetchTarball {
url = "https://github.com/github/semantic/archive/78dad094fa2380aef36cabd48d57f6122f1034ec.tar.gz";
sha256 = "0bk7f96fm9928nc2yv85cwchk43xh4yikbiqg7ngba5q6gj7xy04";
};
pkgs = import nixpkgs-src { config.allowBroken = true; };
@vaibhavsagar
vaibhavsagar / 2SAT.hs
Last active February 13, 2019 04:22
A series of 2SAT checker refactorings
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Graph as G
import qualified Data.Array as A
import qualified Prelude as P
import Prelude hiding (lookup, read, replicate)
@vaibhavsagar
vaibhavsagar / KVStore.hs
Created January 24, 2017 03:01
A simple key-value store.
#!/usr/bin/env stack
{- stack --resolver lts-7 --install-ghc runghc
--package aeson
--package servant-server
--package text
--package transformers
--package unordered-containers
--package warp
-}
@vaibhavsagar
vaibhavsagar / default.nix
Created January 30, 2018 08:39
Nix expression for Exference
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, base-orphans, bifunctors, containers
, data-pprint, deepseq, deepseq-generics, directory, either
, hashable, haskell-src-exts, hood, lens, mmorph, mtl, multistate
, parsec, pqueue, pretty, process, safe, split, stdenv
@vaibhavsagar
vaibhavsagar / Owl.hs
Created October 5, 2017 00:19
Fun with (.).(.)
module Owl where
import System.FilePath ((</>))
fromMaybe :: a -> Maybe a -> a
fromMaybe a m = case m of
Nothing -> a
Just b -> b
prependPath :: FilePath -> FilePath -> FilePath
@vaibhavsagar
vaibhavsagar / count8s.hs
Created February 21, 2017 22:57
Code Dojo 35 with @dalecr
import Data.List
count8s number = let
len = length $ filter (\string -> (read string :: Int) `mod` 8 == 0) $ tail $ subsequences number
in len `mod` (10^9+7)
@vaibhavsagar
vaibhavsagar / Leftovers.ipynb
Created December 20, 2016 04:24
Zlib decompression with leftovers.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vaibhavsagar
vaibhavsagar / code-dojo-2016-11-29.hs
Created November 29, 2016 23:09
Code Dojo solution
import Data.List (inits, tails)
partitionSum [] n = n
partitionSum ls n = let
pairs = zip (tail $ inits ls) (tail $ tails ls)
pass = filter (\(l,r) -> (sum l) == (sum r)) pairs
maxes = map (\(l,r) -> max (partitionSum l (n+1)) (partitionSum r (n+1))) pass
in if (maxes == []) then n else (maximum maxes)
@vaibhavsagar
vaibhavsagar / empty-producer.hs
Last active November 27, 2016 22:21
Reproduction of a different bug in pipes-zlib(?)
#!/usr/bin/env stack
{- stack
--resolver lts-6.24
runghc
--package attoparsec
--package pipes-bytestring
--package containers
--package pipes-zlib -}
{-# LANGUAGE OverloadedStrings #-}