Skip to content

Instantly share code, notes, and snippets.

Avatar
🥺

Ting-gan LUA banacorn

🥺
  • Academia Sinica
  • Taipei, Taiwan
View GitHub Profile
View gist:1437600
{io} = require './server'
net = require 'net'
{EventEmitter} = require 'events'
EE = new EventEmitter
# TCP/IP
server = net.createServer (client) ->
console.log 'client connected'
client.on 'end', ->
View gist:2357819
// net 模組
var net = require('net');
// 建立一個 TCP 伺服器,當有人建立連線時就 ...
var server = net.Server(function (socket) { // 連線會當參數傳進來
// 當有資料從這連線傳過來時就 ...
socket.on('data', function (data) { // 資料會當參數傳進來
// 輸出到 console
View README.md

HaskellFuck

Compile

ghc bf.hs

Hello World

View euler1.hs
sum [a | a <- [1..1000], mod a 3 == 0 && mod a 5 == 0]
@banacorn
banacorn / gist:3434516
Created Aug 23, 2012
The repo your repo could be like!
View gist:3434516
Hello, ladies...
Look at your repo,
Now back to me,
Now back at your repo,
Now back to me.
Sadly, it isn't me, but if it stopped using nothing at all and switched to Travis CI
it could be like it's me.
@banacorn
banacorn / logic.agda
Created Sep 6, 2012
some higher order dependently typed polymorphic awesome shit
View logic.agda
module Logic where
open import Function using (const; _∘_)
open import Data.Unit using (⊤; tt)
open import Data.Bool using (Bool; false; true; not; _∨_; if_then_else_)
open import Data.Nat using (ℕ; zero; suc; _≟_; _+_)
open import Data.List using (List; []; _∷_; map; _++_)
open import Data.Product using (Σ; _,_; _×_)
open import Relation.Nullary using (Dec; yes; no)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; inspect; [_])
@banacorn
banacorn / fa.hs
Created Sep 24, 2012
Deterministic & Non-deterministic Finite Automaton
View fa.hs
import Data.Set
type State = String
type Alphabet = Char
type Language = String
type States = Set State
type Alphabets = Set Alphabet
type Transition = State -> Alphabet -> State
type NDTransition = State -> Alphabet -> States
View fib.hs
import Data.List
import Data.Bits
fib :: Int -> Integer
fib n = snd . foldl' fib' (1, 0) . dropWhile not $
[testBit n k | k <- let s = bitSize n in [s-1,s-2..0]]
where
fib' (f, g) p
| p = (f*(f+2*g), ss)
| otherwise = (ss, g*(2*f-g))
View schriftart.md
  • avenir
  • asap
  • oldenburg
  • museo slab
  • monda
  • economica
  • lato
  • iterstatecondmono
  • oxygen
  • rambla
View banana.hs
adapter :: (Ptr CUChar -> CUInt -> Ptr CUChar -> Ptr CUInt -> IO CInt) -> Int -> String -> String
adapter function chunkSize content = map cuchar2char $ unsafePerformIO $ do
-- allocate buffers
inputBuffer <- mallocArray chunkSize
outputBuffer <- mallocArray chunkSize
outputSize <- mallocBytes 32
-- put it in
pokeArray inputBuffer (map char2cuchar content)
poke outputSize (fromIntegral chunkSize)