Skip to content

Instantly share code, notes, and snippets.

View nonnontrivial's full-sized avatar

Kevin Donahue nonnontrivial

View GitHub Profile
@bouk
bouk / dijkstra.hs
Created January 6, 2013 14:17
Dijkstra's algorithm implemented in Haskell. Example input: 5 7 0 1 2 0 2 7 0 3 6 1 4 6 1 2 3 2 4 5 3 4 1
import Data.List (insert)
fst3 (x,_,_) = x
snd3 (_,x,_) = x
trd3 (_,_,x) = x
toTuple2Int :: String -> (Int, Int)
toTuple2Int s = (read $ takeWhile (/=' ') s :: Int, read $ dropWhile (==' ') $ dropWhile (/=' ') s :: Int)
toTupleTuple2Int :: String -> (Int, (Int, Int))
@syhw
syhw / dnn_compare_optims.py
Created July 21, 2014 09:07
comparing SGD vs SAG vs Adadelta vs Adagrad
"""
A deep neural network with or w/o dropout in one file.
"""
import numpy
import theano
import sys
import math
from theano import tensor as T
from theano import shared
@codyroux
codyroux / a_little_arithmetic.v
Last active September 5, 2017 14:33
An arithmetic development that uses equality over Type rather than Prop.
(* Sigma types *)
(* Inductive Sigma (A:Set)(B:A -> Set) :Set := Spair: forall a:A, forall b : B a,Sigma A B. *)
(* Definition E (A:Set)(B:A -> Set) (C: Sigma A B -> Set) (c: Sigma A B) *)
(* (d: (forall x:A, forall y:B x, C (Spair A B x y))): C c := *)
(* match c as c0 return (C c0) with *)
(* | Spair a b => d a b *)
(* end. *)
@henvic
henvic / main.go
Created October 16, 2017 21:11
Simple dirty example of using Go's json.Marshal and json.Unmarshal
package main
import (
"encoding/json"
"fmt"
"log"
)
// Event to record
type Event struct {
@shobhit6993
shobhit6993 / dijkstra.hs
Created August 11, 2014 19:03
Haskell implementation of the Dijkstra's Single-Source Shortest Path Algorithm.
--sample input
--dijkstra source dest [(n1,n2,e1),(n3,n4,e2)...] [(source,0)]
--dijkstra 1 4 [(1,2,5),(1,3,10),(2,4,100),(3,4,20)] [(1,0)]
--dijkstra 1 5 [(1,2,2), (2,3,1), (3,5,3), (4,5,4), (1,4,5), (1,3,8)] [(1,0)]
--ouput
-- a list of tuples with each tuple (n1,d1) representing the min. dist d1 of node n1 from source
inf = 100000

From zero to microservice with 𝚫 now

The following guide will show you how to deploy a simple microservice written in JavaScript using 𝚫 now.

It uses Open Source tools that are widely available, tested and understood:

  • Node.JS
  • NPM
  • Express
@karpathy
karpathy / gist:7bae8033dcf5ca2630ba
Created May 5, 2015 07:31
Efficient LSTM cell in Torch
--[[
Efficient LSTM in Torch using nngraph library. This code was optimized
by Justin Johnson (@jcjohnson) based on the trick of batching up the
LSTM GEMMs, as also seen in my efficient Python LSTM gist.
--]]
function LSTM.fast_lstm(input_size, rnn_size)
local x = nn.Identity()()
local prev_c = nn.Identity()()
local prev_h = nn.Identity()()
@debasishg
debasishg / gist:b4df1648d3f1776abdff
Last active January 20, 2021 12:15
another attempt to organize my ML readings ..
  1. Feature Learning
  1. Deep Learning
@callistabee
callistabee / mergesort.lhs
Last active February 10, 2021 06:39
Haskell Implementation of Mergesort
- Haskell Mergesort
- Copyright (C) 2014 by Kendall Stewart
First we define a couple of helper functions that
will be useful in splitting the list in half:
> fsthalf :: [a] -> [a]
> fsthalf xs = take (length xs `div` 2) xs
@kangax
kangax / quicksort.hs
Last active September 5, 2021 19:44
Haskell-inspired quick sort in ES6
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort (filter (<=x) xs)
biggerSorted = quicksort (filter (>x) xs)
in smallerSorted ++ [x] ++ biggerSorted