Skip to content

Instantly share code, notes, and snippets.

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@hardentoo
hardentoo / tmux-cheatsheet.markdown
Created April 3, 2017 18:31 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@hardentoo
hardentoo / gist:c20afa6e90aa917a69759fb755dd60a5
Created October 3, 2017 23:19 — forked from simonmichael/gist:1185421
ghc-pkg-clean, ghc-pkg-reset
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@hardentoo
hardentoo / somesquares.hs
Created October 10, 2017 05:27 — forked from ali-abrar/somesquares.hs
Simple Canvas Example
{-# LANGUAGE ScopedTypeVariables #-}
import Reflex.Dom
import GHCJS.DOM.CanvasRenderingContext2D (putImageData, setFillStyle, fillRect)
import GHCJS.DOM.HTMLCanvasElement (getContext)
import GHCJS.DOM.ImageData (newImageData')
import Control.Monad.IO.Class (liftIO)
import GHCJS.DOM.Types (CanvasStyle(..), CanvasRenderingContext2D(..), toJSString, castToHTMLCanvasElement)
import GHCJS.Marshal (toJSVal)
import Data.Time (getCurrentTime)
@hardentoo
hardentoo / integer_partitions.hs
Created October 12, 2017 01:52 — forked from imeckler/integer_partitions.hs
Integer partitions in haskell
ps = [] : map parts [1..]
where parts n = [n] : [x : p | x <- [1..n], p <- ps !! (n - x), x <= head p]
@hardentoo
hardentoo / PipeChat.hs
Created October 12, 2017 01:53 — forked from imeckler/PipeChat.hs
Pipes chat server
{-# LANGUAGE LambdaCase, DeriveGeneric, NamedFieldPuns, RecordWildCards, OverloadedStrings #-}
module Main where
import Pipes
import qualified Pipes.Prelude as P
import Pipes.Network.TCP
import qualified Data.ByteString as B
import qualified Data.HashTable.IO as H
import System.IO.Unsafe
import Data.Serialize
@hardentoo
hardentoo / BFS.hs
Created October 12, 2017 01:55 — forked from imeckler/BFS.hs
BFS
{-# LANGUAGE LambdaCase #-}
import Control.Applicative
import Control.Monad.State
import System.Random
data Tree a = Empty | Bin a (Tree a) (Tree a)
deriving Show
-- O(n)
@hardentoo
hardentoo / pipeline.hs
Created October 12, 2017 01:56 — forked from imeckler/pipeline.hs
Haskell pipeline
{-# LANGUAGE GADTs #-}
import Data.Char (digitToInt)
data Nil
data Cons a b
data Pipeline ts a c where
(:>) :: (a -> b) -> Pipeline ts b c -> Pipeline (Cons (a -> b) ts) a c
Id :: Pipeline Nil t t
@hardentoo
hardentoo / gist:d5c5e364d6ec982b115c2c95b43b62e6
Created October 12, 2017 20:00 — forked from mikehaertl/gist:3258427
Learn you a Haskell - In a nutshell

Learn you a Haskell - In a nutshell

This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.


1. Introduction

  • Haskell is a functional programming language.
@hardentoo
hardentoo / index.html
Created October 18, 2017 00:46 — forked from wavewave/index.html
ghcjs canvas example
<!DOCTYPE html>
<html>
<head>
<script language="javascript" src="lib.js"></script>
<script language="javascript" src="rts.js"></script>
<script language="javascript" src="lib1.js"></script>
<script language="javascript" src="out.js"></script>
</head>
<body>
<canvas id="mycanvas" width="600" height="400"></canvas>