Skip to content

Instantly share code, notes, and snippets.

View herberteuler's full-sized avatar

Guanpeng Xu herberteuler

  • Burnaby, BC, Canada
  • 11:25 (UTC -07:00)
View GitHub Profile
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.List;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.List;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler.Sharable;
@herberteuler
herberteuler / MyStateT.hs
Created March 25, 2015 10:19
Implementing MyStateT
data MyStateT s m a = MyStateT (s -> m (a, s))
runStateT :: MyStateT s m a -> s -> m (a, s)
runStateT = \ (MyStateT f) s -> f s
get :: Monad m => MyStateT s m s
get = MyStateT $ \ s -> return (s, s)
put :: Monad m => s -> MyStateT s m ()
put = \ s -> MyStateT $ \ s' -> return ((), s)
case class Foo(s: String, n: Int)
class MyClient(url: URL) extends featherbed.Client(url) {
override def clientTransform(client: Http.Client) = {
client.withSessionPool.maxSize(1)
}
}
val client = new MyClient(new URL("http://localhost:8766/api/"))
val req = client.post("foo/bar")
import numpy as np
import tensorflow as tf
def input_fn():
def parse(tensor):
return tensor[:3], tensor[-1:]
ds = tf.data.Dataset.from_tensor_slices(np.random.random_sample([10,4]))
ds = ds.map(parse).batch(10).repeat(5)
return ds
import numpy as np
import tensorflow as tf
def input_fn():
def parse(tensor):
return tensor[:3], tensor[-1:]
ds = tf.data.Dataset.from_tensor_slices(np.random.random_sample([10,4]))
ds = ds.map(parse).batch(10).repeat(5)
return ds
import dask.array as da
import numpy as np
arr = da.from_array(np.arange(9).reshape(3,3))
a = da.min(arr)
b = da.max(arr)
quantiles = da.linspace(a, b, 4)
print(np.array(quantiles))
# Traceback (most recent call last):
with import <nixpkgs> {};
(let
my-python =
let packageOverrides = self: super: {
dask = super.dask.overridePythonAttrs (old: rec {
version = "2.15.0";
src = super.fetchPypi {
inherit (old) pname;
{ lib
, stdenv
, patchelf
, fetchurl
, coreutils
, python3
, writeTextFile
, makeWrapper
, requireFile
, alsa-lib