Skip to content

Instantly share code, notes, and snippets.

@ericxyan
ericxyan / http-stream-file.hs
Created March 14, 2016 18:34 — forked from singpolyma/http-stream-file.hs
Stream a file as it is created (such as a video)
module Main (main) where
import Control.Monad (forever, when)
import System.Environment (getArgs)
import System.IO (withBinaryFile, hIsEOF, IOMode(ReadMode), hSetBuffering, BufferMode(BlockBuffering))
import Control.Concurrent (threadDelay)
import Blaze.ByteString.Builder.ByteString (fromByteString)
import Data.ByteString (ByteString)
import Data.ByteString as BS
import Data.Text as T
import {Hero} from './hero';
import {HEROES} from './mock-heroes';
import {Injectable} from 'angular2/core';
@Injectable()
export class HeroService {
getHeroes() {
return Promise.resolve(HEROES);
}
// See the "Take it slow" appendix
getHeroesSlowly() {
@ericxyan
ericxyan / Python notes.py
Created November 5, 2015 21:25
My study notes
# Python 2.7
# 1. Iterator
def f(n):
return [x**4 for x in range(n)]
def f2(n):
for x in range(n):
yield x**3
# Check if is a prime
def isPrime(n):