Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Asymmetric Finance
  • /dev/null
View GitHub Profile
@labra
labra / exampleLocalReader.scala
Last active September 8, 2016 12:34
Example using eff-cats localReader
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
import cats.implicits._
object ExampleLocalReader {
def exampleInterpreter = {
type Env = Map[String,Int]
package ca
import scalaz.{Comonad, NonEmptyList, Zipper}
import Zipper._
case class Board[A](p: Zipper[Zipper[A]]) {
def up = Board(p.previous.get)
def down = Board(p.next.get)
def left = Board(p.map(_.previous.get))
def right = Board(p.map(_.next.get))
// quick translation from http://www.geeksforgeeks.org/inplace-m-x-n-size-matrix-transpose/
def matrixInplaceTranspose[A](a: Array[A], rows: Int, columns: Int): Unit = {
val size = rows * columns - 1
// bitset<HASH_SIZE> b; // hash to mark moved elements
val b = new collection.mutable.BitSet(size)
b.add(0)
b.add(size)
var i = 1; // Note that A[0] and A[size-1] won't move
while (i < size) {
@noelboss
noelboss / git-deployment.md
Last active April 25, 2024 10:38
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

import java.io.{File, FileInputStream}
import java.util
import monix.execution.Cancelable
import monix.reactive.Observable
import scala.util.control.NonFatal
def fromInputStream(in: java.io.InputStream, chunkSize: Int = 256): Observable[Array[Byte]] = {
val iterator = new Iterator[Array[Byte]] {
private[this] val buffer = new Array[Byte](chunkSize)
private[this] var lastCount = 0
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@jdsgomes
jdsgomes / DeepLearningFaces.md
Last active January 6, 2020 07:01
Deep Learning for Face Recognition

Deep Learning for Face Recognition (May 2016)

Popular architectures

  • FaceNet (Google)
    • They use a triplet loss with the goal of keeping the L2 intra-class distances low and inter-class distances high
  • DeepID (Hong Kong University)
    • They use verification and identification signals to train the network. Afer each convolutional layer there is an identity layer connected to the supervisory signals in order to train each layer closely (on top of normal backprop)
  • DeepFace (Facebook)
    • Convs followed by locally connected, followed by fully connected
@non
non / beala.scala
Created May 9, 2016 00:07
Demo using Cats/Dogs to implement lazy memoization, similar to this Haskell gist: https://gist.github.com/beala/d871ae8397167e7035f218a25ddf87dd
package beala
import dogs._
object Beala {
// ironically dogs doesn't support unsafe operations by default,
// so we have to build them ourselves (since we know our stream
// is infinite and will always have elements).
def head[A](as: Streaming[A]): A =
@beala
beala / fibsMemo.hs
Created May 8, 2016 23:25
Elegant memoization in Haskell with laziness.
import Control.Monad.State.Strict
import qualified Data.Map.Strict as Map
-- This is the standard fibonacci implementation with exponential complexity.
naiveFibs :: Int -> Integer
naiveFibs 0 = 0
naiveFibs 1 = 1
naiveFibs n = naiveFibs (n-2) + naiveFibs (n-1)
-- For reference, calculating the 35th fibonacci takes 9.49 sec.