This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec scala -Dscala.concurrent.context.minThreads=16 -Dscala.concurrent.context.maxThreads=64 "$0" "$@" | |
!# | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
import java.util.concurrent.Executors | |
import scala.concurrent._ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent._ | |
import ExecutionContext.Implicits.global | |
object Main extends App { | |
def repeatEvery[T](timeoutMillis: Int)(f: => T): Future[T] = { | |
val p = Promise[T]() | |
val never = p.future | |
f | |
def timeout = Future { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
print("Multiplication table") | |
for a in range(0, 11): | |
print("=============") | |
for b in range(0, 11): | |
print(str(a) + " x " + str(b) + " = " + str(a * b)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install protobuf | |
sudo dnf install protobuf* | |
# install bazel | |
# https://docs.bazel.build/versions/master/install-redhat.html | |
sudo dnf copr enable vbatts/bazel | |
sudo dnf install bazel | |
# get TF src | |
git clone https://github.com/tensorflow/tensorflow.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo dnf install docker | |
# Start/enable service | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
# Allow docker to run without sudo/root privs | |
sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker | |
newgrp docker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_of_1 = lambda i: i == 1 | |
set_of_1(1) | |
set_of_1(2) | |
empty = lambda i: False | |
empty(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
import math._ | |
// The Expression Problem and my sources: | |
// http://stackoverflow.com/questions/3596366/what-is-the-expression-problem | |
// http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/ | |
// http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/ | |
// http://www.ibm.com/developerworks/library/j-clojure-protocols/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NamedFieldPuns #-} | |
-- The Expression Problem and my sources: | |
-- http://stackoverflow.com/questions/3596366/what-is-the-expression-problem | |
-- http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/ | |
-- http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/ | |
-- http://www.ibm.com/developerworks/library/j-clojure-protocols/ | |
-- To begin demonstrating the problem, we first need some |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_subarray(xs): | |
if not xs: | |
return [], 0 | |
start = 0 | |
end = 1 | |
cur_sum = 0 | |
max_sum = xs[0] | |
for i in range(len(xs)): | |
tmp_sum = cur_sum + xs[i] | |
if xs[i] > tmp_sum: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def height_min_max(tree): | |
if not tree: | |
return 0, 0 | |
else: | |
_, l, r = tree | |
lmin, lmax = height_min_max(l) | |
rmin, rmax = height_min_max(r) | |
return 1 + min(lmin, rmin), 1 + max(lmax, rmax) | |