Skip to content

Instantly share code, notes, and snippets.

View eccstartup's full-sized avatar
🈲
I may be slow to respond.

Yi Lu eccstartup

🈲
I may be slow to respond.
View GitHub Profile
@eccstartup
eccstartup / RSS.py
Created December 16, 2012 12:49 — forked from mnot/RSS.py
#!/usr/bin/env python
"""
RSS.py
Classes for working with RSS channels as arbitrary data structures.
Requires Python 2.2 or newer and PyXML 0.7.1 or newer.
ChannelBase - Base class for RSS Channels.
CollectionChannel - RSS Channel modeled as a URI-per-entry

Scientific Python From Source

This document will walk you through compiling your own scientific python distribution from source, without sudo, on a linux machine. The core numpy and scipy libraries will be linked against Intel MKL for maximum performance.

This procedure has been tested with Rocks Cluster Linux 6.0 (Mamba) and CentOS 6.3.

Compiling Python From Source

#!/bin/sh
echo "Cleaning up..."
rm 00-index.tar.gz
mkdir -p package
echo "Downloading index..."
wget http://hackage.haskell.org/packages/archive/00-index.tar.gz
for splitpk in `tar tf 00-index.tar.gz | cut -d/ -f 2,3`; do
pk=`echo $splitpk | sed 's|/|-|'`
name=$pk.tar.gz
Fibonacci sequence
> fibonacciList = 1:1:zipWith (+) (tail fibonacciList) fibonacciList
Prime number sequence
> primeList = 2 : let oddList = [3,5..] in filter (\n-> and $ map (\x-> rem n x /= 0) $ takeWhile (\x -> x <= floor (fromIntegral n**(0.5))) primeList) oddList
Binomial coefficients for each order, called Pascal's Triangle
> pascalTriangleList = let fetch2 = (\(m,list) -> let ls = 1:map (\n->sum $ (take 2.drop n) list) [0..floor $ fromIntegral (m-1)/2] in ls ++ (if odd m then drop 1 else id) (reverse ls)) in [1]:[1,1]: (map fetch2 $ zip [1..] $ tail pascalTriangleList)
-- find md5sum of a string
import Data.Digest.OpenSSL.MD5
import Data.ByteString.Char8
findMD5 s = md5sum $ pack $ s
@eccstartup
eccstartup / .profile
Created September 2, 2013 08:22
part of .profile files how to define colorful $ls and $PS1
#Colorful configurations for Terminal
export TERM="xterm-color"
PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;36m\]\w\[\e[0m\]\$ '
alias ls="ls -G"
export LSCOLORS="gxfxcxdxbxegedabagacad"
--code
```
main = do
putStrLn "Type something:"
l <- getLine
putStrLn $ "You typed:" ++ l
main
```
------
gcc -o hello1 hello.c
```
hello.c:5:28: error: jhc_rts_header.h: No such file or directory
hello.c:21: error: expected specifier-qualifier-list before ‘sptr_t’
hello.c:24: error: expected ‘)’ before ‘gc’
hello.c:26: error: expected ‘)’ before ‘gc’
hello.c:27: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fPrelude_IO_getChar’
hello.c:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fPrelude_IO_getLine’
hello.c:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fPrelude_IO_putStr’
autoreconf -i
```
configure.ac:17: installing 'ac-macros/compile'
configure.ac:13: installing 'ac-macros/config.guess'
configure.ac:13: installing 'ac-macros/config.sub'
configure.ac:5: installing 'ac-macros/install-sh'
configure.ac:5: installing 'ac-macros/missing'
```
=============
import Control.Applicative
import Control.Monad
import Data.Char
import Data.List
import System.IO
num2wstr :: Integer -> Maybe [String]
num2wstr 0 = Just []
num2wstr n | n < 0 = (:) <$> Just "minus" <*> (num2wstr $ abs n)