Skip to content

Instantly share code, notes, and snippets.

@soumyasd
soumyasd / Db.scala
Created November 4, 2015 02:15 — forked from rodolfo42/Db.scala
How to use transactions with finagle-mysql
package transactions
import com.twitter.finagle.exp.mysql.{Client, OK, Result}
class Db(mysqlClient: Client) {
val insertOrder = "INSERT INTO orders (ref) VALUES(?)"
val insertOrderItem = "INSERT INTO order_items (order_id, item_id) VALUES(?, ?)"
def persistOrderWithItems[T](order: Order)(whenDone: (OK, Seq[Result]) => T): Future[T] = {
@soumyasd
soumyasd / S3UploadStream.scala
Created December 21, 2015 01:02 — forked from th0br0/S3UploadStream.scala
play-s3 streaming upload
package lib
import fly.play.s3._
import java.io.OutputStream
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import play.api.http.ContentTypeOf
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.libs.concurrent.Akka
@soumyasd
soumyasd / springer-free-maths-books.md
Created December 29, 2015 01:44 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
import math
import random
def get_random_neighbour(state):
neighbour = [house[:] for house in state] # Deep copy
i = random.randint(0, 4)
j = random.choice(range(0, i) + range(i+1, 4))
attr_idx = random.randint(0, 4)
@soumyasd
soumyasd / resnet_all_conv.py
Created April 21, 2017 14:25 — forked from EderSantana/resnet_all_conv.py
Resnet + all conv implementation example
"""
Possibly correct implementation of an all conv neural network using a single residual module
This code was written for instruction purposes and no attempt to get the best results were made.
References:
Deep Residual Learning for Image Recognition: http://arxiv.org/pdf/1512.03385v1.pdf
STRIVING FOR SIMPLICITY, THE ALL CONVOLUTIONAL NET: http://arxiv.org/pdf/1412.6806v3.pdf
A video walking through the code and main ideas: https://youtu.be/-N_zlfKo4Ec
@soumyasd
soumyasd / multi-ts-lstm.py
Created July 31, 2017 11:48 — forked from lukovkin/multi-ts-lstm.py
Time series prediction with multiple sequences input - LSTM - 1
# Time Series Testing
import keras.callbacks
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dense, Dropout
from keras.layers.recurrent import LSTM
# Call back to capture losses
class LossHistory(keras.callbacks.Callback):
def on_train_begin(self, logs={}):
self.losses = []