Skip to content

Instantly share code, notes, and snippets.

View sshine's full-sized avatar
🦀

Simon Shine sshine

🦀
View GitHub Profile
m <- matrix(c(1, 0, 0,
0, 4, 0,
0, 0, 2), ncol=3, byrow=T)
replaceEs :: String -> String
-- One way
replaceEs ('e':cs) = 'a' : replaceEs cs
replaceEs (c:cs) = c : replaceEs cs
replaceEs [] = []
-- Or another
replaceEs [] = []
replaceEs (c:cs) =
case c of
from __future__ import division
## Equations:
# x(t+h) = x(t) + 1/2 (F1 + F2)
# F1 = h*f(t,x)
# F2 = h*f(t+h, x+h*f(t,x))
def rungekutta(f, a, b, x0, iterations):
h = (b - a) / iterations
x = x0
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module WorkspaceOverviewPopup where
import Data.Maybe
import Control.Monad
import XMonad
import qualified XMonad.StackSet as W
import XMonad.Layout.LayoutModifier
import XMonad.Util.Font
minima :: Ord a => [a] -> [a]
minima [] = []
minima (y:xs) = foldr aux [y] xs
where aux x result =
case x `compare` head result of
LT -> [x]
EQ -> x:result
GT -> result
@sshine
sshine / keybase.md
Last active September 15, 2016 12:59

Keybase proof

I hereby claim:

  • I am sshine on github.
  • I am sshine (https://keybase.io/sshine) on keybase.
  • I have a public key ASBgprI2XryI_tASbgYfLUjHl1-zCW53t7A8TpIl7OXGvAo

To claim this, I am signing this object:

-module(transact).
-export([ start_server/1, start_transaction/1,
modify_state/3, commit_transaction/2 ]).
%%%%%%%
rpc_send(Pid, Msg) ->
Pid ! {self(), Msg},
receive
{reply, Reply} ->
@sshine
sshine / keyservers.txt
Created October 9, 2014 13:20
Keyserver exercise
Keyservers:
A keyserver is a repository for cryptographic keys. A person can upload their
keys to a keyserver, and other persons can retrieve the key if they want to
send them an encrypted message.
To avoid a keyserver being compromised, several keyservers can be connected
and share their databases. So if one server has its keys changed, the other
servers can
@sshine
sshine / qc.hs
Last active August 29, 2015 14:07
import Test.QuickCheck
import Text.ParserCombinators.ReadP
import Control.Monad
import Control.Applicative hiding (Const)
data Tree = Leaf Int
| Branch Tree Tree
deriving (Show)
import Text.ParserCombinators.ReadP
import Control.Monad
import Data.Char
data Exp = Add Exp Exp
| Mul Exp Exp
| Num Int
| Dbl Double
| Neg Exp