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
trait Generator[+T] { | |
self => | |
def generate: T | |
def map[S](f: T => S): Generator[S] = new Generator[S] { | |
def generate = f(self.generate) | |
} | |
def flatMap[S](f: T => Generator[S]): Generator[S] = new Generator[S] { |
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
open Devart.Data | |
open Devart.Data.Oracle // http://www.devart.com/dotconnect/oracle/download.html | |
open FSharp.Control // https://github.com/tpetricek/FSharp.AsyncExtensions | |
open System | |
open System.Data | |
let sql = "SELECT * FROM {}" | |
let tables = [|"t1";"t2";"t3";"t4";"t5";"t6"|] |
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
open Devart.Data | |
open Devart.Data.Oracle // http://www.devart.com/dotconnect/oracle/download.html | |
open FSharp.Control // https://github.com/tpetricek/FSharp.AsyncExtensions | |
open System | |
open System.Data | |
let sql = "SELECT * FROM {}" | |
let tables = [|"t1";"t2";"t3";"t4";"t5";"t6"|] |
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 os | |
import glob | |
from datetime import date, timedelta | |
import re | |
from time import gmtime, strftime | |
folder = '<Insert folder name here>' | |
files = ['FileA.txt', 'FileB.txt'] | |
archivePeriod = 5 # archive period in days |
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 os | |
cap = 1 # cap in Megabytes | |
from datetime import date, timedelta | |
from time import gmtime | |
cutoffDate = date.today()-timedelta(days=1) # does not delete files newer than this (exclusive of the date) | |
def GetFolderSize(start_path = '.'): #get disk space in Megabytes | |
return sum(os.path.getsize(f) for f in os.listdir('.') if os.path.isfile(f)) / (1024*1024) |
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
class PairOfShoes(var leftSize: Int, var rightSize: Int) { | |
def mix(newLeftSize: Int, newRightSize: Int) = | |
{ | |
leftSize = newLeftSize | |
rightSize = newRightSize | |
} | |
override def hashCode(): Int = leftSize + 31 * rightSize | |
def canEqual(that: Any): Boolean = that match { |
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
// Akka Actor system | |
import akka.actor.ActorSystem | |
// HTTP related imports | |
import spray.http.{ HttpRequest, HttpResponse } | |
import spray.client.pipelining.{ Get, sendReceive } | |
// Futures related imports | |
import scala.concurrent.Future | |
import scala.util.{ Success, Failure } |
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
@table(name="COFFEES") | |
case class Coffee( | |
@column(name="NAME") | |
name : String, | |
@column(name="PRICE") | |
price : Double | |
) |
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
class Coffees(tag: Tag) extends Table[(String, Int, Double, Int, Int)] | |
(tag, "COFFEES") { | |
def name = column[String]("NAME", O.PrimaryKey) | |
def price = column[Double]("PRICE") | |
} |
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
var ts: List[Long] = List.empty | |
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block | |
val t1 = System.nanoTime() | |
val t = t1 - t0 | |
ts = ts ++ List(t) | |
result | |
} |
OlderNewer