Skip to content

Instantly share code, notes, and snippets.

;;(load "/local-home/user18/repos/thirdparty/emacs-haskell-config/init.el")
(add-to-list 'load-path "~/repos/thirdparty/emacs-haskell-config/packages/haskell-mode/")
(require 'haskell-mode-autoloads)
(add-to-list 'Info-default-directory-list "~/repos/thirdparty/emacs-haskell-config/packages/haskell-mode/")
(require 'cl)
(add-to-list 'load-path "~/.emacs.d/lisp")
(require 'cask "~/.cask/cask.el")
#include <rfftw.h>
#include <math.h>
#include <stdio.h>
/* the out format is: */
/* r0, r1, r2, ..., rn/2, i(n+1)/2-1, ..., i2, i1 */
void fft(int n, fftw_real in[n], fftw_real power_spectrum[n/2+1])
{
fftw_real out[n];
rfftw_plan p;
@sinelaw
sinelaw / gen_files_json.hs
Created January 13, 2015 11:16
Generates a json file describing the directory structure
module Main where
import System.Directory (getDirectoryContents)
import Control.Monad (forM_)
import Data.Functor ((<$>))
import System.Posix.Files (getSymbolicLinkStatus, isDirectory)
withIsLast :: [a] -> [(a, Bool)]
withIsLast [] = []
withIsLast [x] = [(x, True)]
@sinelaw
sinelaw / FixT.hs
Created December 25, 2014 20:45
fixed-point type
{-# LANGUAGE FlexibleContexts, FlexibleInstances #-}
module FixT where
data Expr = Val
| Divide Expr Expr
| Times Expr Expr
deriving Show
flipDivide :: Expr -> Expr
flipDivide Val = Val
@sinelaw
sinelaw / test.js
Last active August 29, 2015 14:10
inference
// (c -> c)
// c
var id = function(x) { return x; };
// (i -> i)
// TNumber
var num = id(3);
// (n -> n)
// TString
var str = id('a');
@sinelaw
sinelaw / debounce.js
Created November 13, 2014 14:20
debouncer
function debounce(f, millis) {
var ready = true;
var timeoutId;
var lastMissed;
function resetTimeout(){
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(function() {
if (lastMissed) {
lastMissed();
}
@sinelaw
sinelaw / wikinews.hs
Last active August 29, 2015 14:07
tagsoup web scraping demo
module WikiNews where
import Network.HTTP(simpleHTTP, getRequest, getResponseBody)
import Data.List(isInfixOf, intersperse)
import Data.Char(isSpace, toLower)
import Control.Category((>>>))
import System.Random(getStdGen)
-- from package tagsoup:
Started GET "/api/system_status?_=1412070154562" for 127.0.0.1 at 2014-09-30 12:42:34 +0300
Processing by Api::V1::SystemStatusesController#index as JSON
Parameters: {"_"=>"1412070154562"}
LocalUser Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('LocalUser') AND "users"."id" = 2 ORDER BY "users"."id" ASC LIMIT 1
Completed 500 Internal Server Error in 2ms (Views: 0.1ms | ActiveRecord: 0.2ms)
module Test where
import Data.Maybe
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Maybe(MaybeT(..))
import Control.Monad.State(State, runState, forM, get, put)
positiveOnly :: Int -> Maybe Int
@sinelaw
sinelaw / out.hs
Last active August 29, 2015 14:06
Expr (Call (Expr (LitFunc ["x"]
(Expr (Var "x")
(Right Context {parent = Context {parent = Context {parent = Global,
vars = [],
curType = Top},
vars = [("x",
TVar "x")],
curType = Top},
vars = [],
curType = TVar "x"})))