Skip to content

Instantly share code, notes, and snippets.

View manjuraj's full-sized avatar

Manju Rajashekhar manjuraj

View GitHub Profile
@manjuraj
manjuraj / nginx-proxy-cache.txt
Created June 8, 2016 03:55 — forked from yanmhlv/gist:5612256
nginx proxy_cache
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:5m max_size=1000m;
server {
listen 80;
server_name cache.example.ru;
# кешируемый адрес
location / {
# кеш включен по умолчанию
set $no_cache "";
# отключаем кеш для всех методов, кроме GET и HEAD
if ($request_method !~ ^(GET|HEAD)$) {
@manjuraj
manjuraj / scalaz-applicative.scala
Created July 9, 2015 06:01
scalaz applicative
//
// Apply extends the Functor Typeclass by adding a method `ap` which
// is similar to `map` from Functor in that it takes a functor that
// that has a function in it and another functor and extracts that
// function from the first functor and then maps it over the second
// one
//
// Alternatively, you can say `ap` lets you apply a function in a
// context to a value in a context
//
@manjuraj
manjuraj / scalaz-validation.scala
Last active June 25, 2018 21:01
scalaz validation
//
// Validation[E, A] represents either:
// - Success[A]
// - Failure[E]
//
// Isomporphic to scala.Either[E, A] and scalaz.\/[E, A]
//
// Unlike \/[E, A], Validation is not a Monad, but an Applicative
// Functor. So if you want to use it as a Monad you can convert back
// and forth using the `validation` and `disjunction` method
@manjuraj
manjuraj / scalaz-disjunction.scala
Last active November 12, 2018 16:15
scalaz disjunction
//
// Disjunction - aka Scalaz Either
// \/[A, B] is an alternative to Either[A, B]
// -\/ is Left (usually represents failure by convention)
// \/- is Right (usually represents success by convention)
// Left or Right - which side of the Disjunction does the "-" appear?
//
// Prefer infix notation to express Disjunction Type v: String \/ Double
//
// References
@manjuraj
manjuraj / private-classes.scala
Created July 2, 2015 18:07
private classes in scala
//
// (1). Use a trait, companion object and private class that
// implements trait within the companion object
//
sealed trait Point {
def x: Int
def y: Int
}
object Point {
@manjuraj
manjuraj / private[this].scala
Last active August 29, 2015 14:20
private[this]
//
// private members are visible to the companion class/trait
// and other instances of the class, but private[this]
// members are not
//
// A class member marked private: `private val x: Int = ...`
// is visible to all instances of that class (but not their
// subclasses). In most cases, you want private[this].
//
// `private[this] val x: Int = ...` limits visibility to the
@manjuraj
manjuraj / scalaz-nel.scala
Last active May 16, 2018 20:13
scalaz NonEmptyList (NEL)
//
// NonEmptyList (Nel)
// - A singly-linked list that is guaranteed to be non-empty
// - https://github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/NonEmptyList.scala
//
final class NonEmptyList[+A](val head: A, val tail: List[A]) {
...
}
//
@manjuraj
manjuraj / gist:c1eeb18b58a864902c77
Last active August 29, 2015 14:18
Nvidia GPU specs

GeForce GTX TITAN Z

  • 5760 CUDA cores
  • 12 GB of memory

GeForce GTX Titan X

  • 3072 CUDA cores
  • Big Maxwell
  • 12GB of RAM

GeForce GTX 980

@manjuraj
manjuraj / scalaz.scala
Last active September 29, 2015 00:37
scalaz type constructors
//
// Foldable
// - fold a data structure
// - usually, fold F[A] given a Monoid[A]
//
trait Foldable[F[_]] { self =>
def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B
def foldLeft[A, B](fa: F[A], z: B)(f: (B, A) => B): B = {
@manjuraj
manjuraj / gist:ef1a3aa7435a8fd45f35
Last active March 24, 2017 07:05
TypeTags and Manifest
// References
// - http://docs.scala-lang.org/overviews/reflection/typetags-manifests.html
// - http://stackoverflow.com/questions/12218641/scala-what-is-a-typetag-and-how-do-i-use-it
// - http://blogs.atlassian.com/2012/12/scala-and-erasure/
// - http://www.scala-blogs.org/2008/10/manifests-reified-types.html
// - http://stackoverflow.com/questions/3587286/how-does-scalas-2-8-manifest-work
// - http://stackoverflow.com/questions/3213510/what-is-a-manifest-in-scala-and-when-do-you-need-it
//