Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
import slick.lifted.MappedTypeMapper | |
import java.sql.Date | |
import org.joda.time.DateTime | |
import slick.lifted.TypeMapper.DateTypeMapper | |
object DateTimeMapper { | |
implicit def date2dateTime = MappedTypeMapper.base[DateTime, Date] ( | |
dateTime => new Date(dateTime.getMillis), | |
date => new DateTime(date) |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
data Skew a = Empty | Node a (Skew a) (Skew a) | |
singleton :: Ord a => a -> Skew a | |
singleton x = Node x Empty Empty | |
union :: Ord a => Skew a -> Skew a -> Skew a | |
union t1 Empty = t1 | |
union Emtpy t2 = t2 | |
union t1@(Node x1 l1 r1) t2@(Node x2 l2 r2) | |
| x1 <= x2 = Node x1 (union t2 r1) l1 |
// Define the general Arg type and companion object: | |
import language.higherKinds, language.implicitConversions, language.existentials | |
object Arg { implicit def toArg[Tc[_], T: Tc](t: T): Arg[T, Tc] = Arg(t, implicitly[Tc[T]]) } | |
case class Arg[T, Tc[_]](value: T, typeclass: Tc[T]) | |
// Say, for example we have a typeclass for getting the length of something, with a few instances | |
trait Lengthable[T] { def length(t: T): Int } | |
implicit val intLength = new Lengthable[Int] { def length(i: Int) = 1 } | |
implicit val stringLength = new Lengthable[String] { def length(s: String) = s.length } |
object EventTracker { | |
def isScriptLoaded=js.Dynamic.global.ga.isInstanceOf[js.Function] | |
def sendEvent(category:String,action:String,label:String):Unit={ | |
if (isScriptLoaded) GoogleAnalytics.ga("send","event",category,action,label) | |
} | |
def sendEvent(category:String,action:String,label:String,value:String):Unit={ | |
if (isScriptLoaded) GoogleAnalytics.ga("send","event",category,action,label,value) | |
} | |
} |
In the past, I've written composition functions in both Elm and Haskell that take multiple parameters for the leftmost function, i.e. the function that gets applied first.
(All examples here are in Haskell)
Here was my Haskell implemenation (stolen from the web):
compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
package kronecker | |
import spire.implicits._ | |
/** | |
* Utilities for doing diagonalization in N dimensions. | |
* | |
* The goal here is to be able to support diagonalizations for | |
* arbitrary tuples, e.g. Tuple2, Tuple3, Tuple9, etc. The "dimension" | |
* (or "dim") represents the arity of the tuple: dim=2 would |
Provisional benchmarks of AST-free serialization puts my WIP branch of uPickle about ~40% faster than circe on my current set of ad-hoc benchmarks, if the encoders/decoders are cached (bigger numbers is better)
playJson Read 2761067
playJson Write 3412630
circe Read 6005895
circe Write 5205007
upickleDefault Read 4543628
upickleDefault Write 3814459
upickleLegacy Read 8393416
import scala.language.higherKinds | |
// Whitebox ... | |
trait Schema[T, R] { | |
def conv(t: T): R | |
} | |
object Schema { | |
// Whitebox macro: R is computed from T | |
implicit def mkSchema[T, R]: Schema[T, R] = ??? // macro ... |
#include <ESP8266WiFi.h> | |
#include <WiFiUdp.h> | |
WiFiUDP Udp; | |
const char* ssid = "yourwifiSSID"; | |
const char* password = "yourwifipassword"; | |
const int threshold = 400; //this is the threshold how high the value has to be to be registered as a flash. | |
//400 works great for me since flashes are usually ~600 | |
IPAddress remoteIP(192,168,1,117); // the IP address of your Influxdb server |