Skip to content

Instantly share code, notes, and snippets.

module Main where
import Control.Monad (liftM)
import Numeric.LinearAlgebra (readMatrix, multiply, rank, cols, rows, fromBlocks)
main = do
putStrLn "Enter matrix A (in format \"1 2 3; 4 5 6; 7 8 9\")"
a <- getMatrix
putStrLn "Enter matrix B (in format \"1; 2; 3\")"
import Numeric.LinearAlgebra
import Control.Monad (replicateM)
import System.Random (randomIO)
import Graphics.Gnuplot.Simple (plotFunc)
-- Test 100 random lines for convexity.
main = replicateM 100 $ do
-- Two 5x5 symmetric positive definite matrices that determine the line.
a <- randomSnPD 5
v <- randomSnPD 5
@caiorss
caiorss / recvLn.hs
Last active August 29, 2015 14:23 — forked from crabmusket/recvLn.hs
import qualified Data.ByteString.Char8 as B
import System.Hardware.Serialport (SerialPort, recv)
recvLn :: SerialPort -> IO B.ByteString
recvLn s = do
-- Receive one byte at a time.
first <- recv s 1
rest <- if first == B.singleton '\n'
then return $ B.empty
else recvLn s
-- Imports for serial port
import qualified Data.ByteString.Char8 as B
import System.Hardware.Serialport
(openSerial, recv, closeSerial, defaultSerialSettings)
-- Imports for threading and stuff
import Control.Monad (void, forever, mapM_)
import Control.Concurrent (forkIO, killThread)
import Control.Concurrent.Chan
(Chan, newChan, dupChan, writeChan, getChanContents)
-- http://hackage.haskell.org/package/atom
-- http://hackage.haskell.org/package/atom-msp430
module Main where
import Data.Word
import Data.Bits
import Language.Atom.MSP430
main = mspCompile "g2231" $ mspProgram {
@caiorss
caiorss / run-python.el
Last active August 29, 2015 14:24 — forked from ieure/run-python.el
(defun python-find-python-command (&optional root)
"Return the python interpreter to use for ROOT."
(let ((env-root (local-path
(locate-dominating-file
(or root default-directory) "bin/python"))))
(or (when env-root (concat env-root "bin/python"))
python-python-command)))
(defun python-find-project-root (&optional start)
(defun local-path (path)
"Return the local portion of a path.
If PATH is local, return it unaltered.
If PATH is remote, return the remote diretory portion of the path."
(if (tramp-tramp-file-p path)
(elt (tramp-dissect-file-name path) 3)
path))
(defun python-find-python-command (&optional root)
@caiorss
caiorss / sql.el
Last active August 29, 2015 14:24 — forked from ieure/sql.el
(defun sql-connect* (connection &optional new-name)
(interactive
(list (sql-read-connection "Connection: " nil '(nil))
current-prefix-arg)
nil)
(require 'tramp)
(let ((dir (cadr (assoc 'default-directory
(cdr (assoc connection sql-connection-alist))))))
(if dir
(let ((default-directory dir))
;; Scratch
;; This program helps keep a record of ideas.
;; Last edit: 2012-07-05
;; Every time (scratch) is called a new buffer is opened. Title
;; is today's date appended before a user inputed title.
;Needed features
;* An interactive shell that shows me a list of entries
; from a certain time period.
@caiorss
caiorss / init.el
Last active August 29, 2015 14:24 — forked from zonuexe/init.el
;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
;; for Emacs 24
;;; modes(UI)
(tool-bar-mode -1)
(when (and window-system (>= emacs-major-version 23))
(set-face-attribute 'default nil
:family "Migu 2M"
:height 160))