Skip to content

Instantly share code, notes, and snippets.

@songpp
songpp / Params.hs
Last active August 29, 2015 14:06
a tiny, lovely generic (type indexed) parameter container
-- @Author: spp
-- @Date: 2014-09-26 17:16:53
-- @Last Modified by: spp
-- @Last Modified time: 2014-09-26 17:21:58
{-# LANGUAGE DataKinds, ScopedTypeVariables, DeriveDataTypeable, Rank2Types, ExistentialQuantification #-}
module Params(
Params,
Param,
mkParam,
@songpp
songpp / java_homes.sh
Created July 16, 2014 02:45
OS X打印所有已经安装的java版本以及路径
#! /bin/sh
VERS="1.6 1.7 1.8"
for i in $VERS; do
echo "$i => $(/usr/libexec/java_home -v $i)";
done
import Control.Monad
import System.Exit
import Control.Concurrent
import Control.Concurrent.MVar
data Person = John | Jeff | Emma | Steve | Julie deriving (Show, Enum)
next Julie = John
next p = succ p
@songpp
songpp / Huffman.hs
Last active August 29, 2015 14:01
haskell huffman code
{-# LANGUAGE TupleSections #-}
module Huffman where
import qualified Data.ByteString (ByteString)
import Data.Map (Map)
import qualified Data.Map as Map
data Tree a = Node Int (Tree a) (Tree a) | Leaf a Int deriving Show
data Bit = L | R deriving Show
@songpp
songpp / progress.hs
Last active May 31, 2021 11:30
Haskell download file show progress 下载文件显示下载进度
{-# LANGUAGE OverloadedStrings #-}
import Data.CaseInsensitive ( CI )
import qualified Data.CaseInsensitive as CI
import Control.Monad
import Control.Monad.IO.Class
import Data.Maybe (fromJust)
import Data.ByteString (ByteString)
import Data.ByteString as B
import qualified Data.ByteString.Lazy as L
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
// specific settings file, for example, "Base File (Linux).sublime-settings".
// Because of this, setting them here will have no effect: you must set them
// in your User File Preferences.
"font_face": "Monaco",
"font_size": 12,
@songpp
songpp / .emacs
Created January 6, 2014 14:09
.emacs
(setenv "PATH" (concat (getenv "PATH") ":/opt/X11/bin:/usr/local/bin:~/.cabal/bin"))
(setq exec-path (append exec-path '("/usr/local/bin" "/opt/X11/bin" "~/.cabal/bin")))
(setq x-select-enable-clipboard t)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8-unix)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
@songpp
songpp / clang-xcode5-wrapper.hs
Created December 13, 2013 13:46
clang-xcode5-wrapper
import System.Environment
import System.Process
import Data.List (isInfixOf)
-- | This script wraps clang to pass it essential arguments that keep it from dying when
-- GHC uses it as a C pre-processor during the build process.
-- To use it, choose the version of clang you'd like to use,
-- (GHC-iOS needs to use Xcode5's clang, which is already set here)
-- then compile it (ghc clang-xcode5-wrapper.hs).
-- Then, find your GHC settings file (usually something like /usr/local/lib/ghc-7.6.3/settings)
package test;
import scala.concurrent.util.Unsafe;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
/**
* User: sunflower
@songpp
songpp / types.sc
Created September 21, 2013 12:59
scala sheets
package sheets
import language.existentials
import java.util.ArrayList
import java.util.LinkedList
import scala.collection.mutable.LinkedHashSet
object types {
type T[X] = X => X