Skip to content

Instantly share code, notes, and snippets.

View NCrashed's full-sized avatar
🐢

Anton Gushcha NCrashed

🐢
  • Russia, Moscow
View GitHub Profile
@NCrashed
NCrashed / CityFlood
Last active December 27, 2015 01:59
Haskell solution for http://habrahabr.ru/post/200190/
module Main where
import qualified Data.Vector as V
printArray :: (Integral a, Show a) => V.Vector a -> IO ()
printArray x = mapM_ printLine $ reverse [1 .. maxElem]
where
printLine n = (putWithOffset $ show n) >> mapM_ (putFiller n) [0 .. (V.length x)-1] >> putChar '\n'
putWithOffset s
| length s < numberOffset = putStr s >> mapM_ (\x -> putChar ' ') [1 .. (length s) - numberOffset]
@NCrashed
NCrashed / StringCalculator
Created December 31, 2013 17:02
Haskell string calculator. It correctly handles parentness, binary operators (+,-,*,/,^), unary operators (-,!) and is built on Parsec-like parsing style.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Control.Monad (forever)
import Data.Maybe (catMaybes)
import Data.List (find)
data Expression =
ExprLiteral Double
@NCrashed
NCrashed / .travis.yml
Created April 6, 2014 15:24
TravisCI config for D programming language
language: d
install:
- DMD_VER=2.065.0
- DMD=dmd_${DMD_VER}-0_amd64.deb
- DUB_VER=0.9.21
- DUB=dub-${DUB_VER}-linux-x86_64
- wget http://downloads.dlang.org/releases/2014/${DMD}
- sudo dpkg -i ${DMD} || true
- sudo apt-get -y update
@NCrashed
NCrashed / bugs.hs
Last active August 29, 2015 14:10
FPChallenge December 2014
import UU.PPrint hiding ((<$>))
import Data.List (nub, sortBy, elemIndex, groupBy)
import Data.Function (on)
import Data.Functor ((<$>))
import Data.Maybe (fromJust, fromMaybe)
import Control.Arrow (first, second)
import GHC.Exts (the)
data Tree a b = Tree a [(b, Tree a b)]
@NCrashed
NCrashed / Let.idr
Last active November 16, 2016 07:20
Idris fast implementation of let evaulation
VarName : Type
VarName = Nat
total
nameEq : (a : VarName) -> (b : VarName) -> Dec (a = b)
nameEq Z Z = Yes Refl
nameEq Z (S k) = No ZnotS
nameEq (S k) Z = No (negEqSym ZnotS)
nameEq (S k) (S j) with (nameEq k j)
| Yes p = Yes $ cong p
@NCrashed
NCrashed / GraphPath.idr
Created November 29, 2016 00:33
Play with Idris to prove correct way of building paths in directed graph and proof of properties of the paths
module Path
import Data.Vect
||| Graph defined by hops vector
Ways : Nat -> Type -> Type
Ways n a = Vect n (a, a)
||| Helper that points which transaction ways we need to use to traverse the given path
data PathElem : (ways : Ways k a) -> (begin : a) -> (path : Vect n a) -> (end : a) -> Type where
{-# LANGUAGE OverloadedLists #-}
module Main where
import Data.Vector.Unboxed (Vector(..), fromList, (!?))
import Data.List
import Data.Maybe (isJust)
import qualified Data.Vector.Unboxed as V
hasCycle1 :: (V.Unbox a, Eq a) => Vector a -> Bool
@NCrashed
NCrashed / patch_elf
Created November 7, 2018 21:29
NixOS Northguard
# Patch ./linux/hl
patchelf --set-interpreter /nix/store/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/ld-linux-x86-64.so.2 ./linux/hl
@NCrashed
NCrashed / shell.nix
Created December 2, 2018 12:37
nix rust shell
# Latest Nightly
with import <nixpkgs> {};
let src = fetchFromGitHub {
owner = "mozilla";
repo = "nixpkgs-mozilla";
rev = "b9c99d043b1cb55ee8c08265223b7c35d687acb9";
sha256 = "0akyhdv5p0qiiyp6940k9bvismjqm9f8xhs0gpznjl6509dwgfxl";
};
in
with import "${src.out}/rust-overlay.nix" pkgs pkgs;
@NCrashed
NCrashed / configuration.nix
Last active February 27, 2019 21:25
configuration_kde_laptop.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, lib, pkgs, ... }:
with lib;
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix