Skip to content

Instantly share code, notes, and snippets.

View nachinius's full-sized avatar
🐻
Working...

nachinius nachinius

🐻
Working...
  • Berlin, DE
  • 03:39 (UTC +01:00)
View GitHub Profile
pragma solidity >=0.4.22 <0.6.0;
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This constructor is executed at initialization and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
pragma solidity >=0.4.22 <0.6.0;
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This constructor is executed at initialization and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
pragma solidity >=0.4.22 <0.6.0;
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This constructor is executed at initialization and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
@nachinius
nachinius / MortalPayableGreeter.solidty
Created December 6, 2018 17:38
A contract that can receive money in its address, can be killed, and is a greeter.
pragma solidity >=0.4.22 <0.6.0;
contract Mortal {
/* Define variable owner of the type address */
address owner;
/* This constructor is executed at initialization and sets the owner of the contract */
constructor() public { owner = msg.sender; }
/* Function to recover the funds on the contract */
@nachinius
nachinius / alpakka_on_2_11.sh
Created March 21, 2018 16:53
compile alpakka for 2.11
#!/bin/sh
find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete
sbt -J-XX:ReservedCodeCacheSize=128m ++2.11.12 ";test:compile;docs/paradox"

Advanced Functional Programming with Scala - Notes

Copyright © 2016-2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@nachinius
nachinius / Tree.scala
Created January 17, 2018 18:00
A simple tree sealed trait with K key and V value types, has eulertour and is traversable
sealed trait Tree[K, V] extends Traversable[Tree[K,V]] {
self =>
type Key = K
type Value = V
def eulerTourWithLevel[U, W, Y](level: Int)(in: Int => Tree[K, V] => U,
middle: Int => Tree[K, V] => W,
out: Int => Tree[K, V] => Y): Unit
@nachinius
nachinius / .travis.yml
Created December 13, 2017 01:59
scala with coveralls
language: scala
scala:
- 2.12.4
script:
- sbt clean coverage test coverageReport &&
sbt coverageAggregate
after_success:
- sbt coveralls
@nachinius
nachinius / sprayjsonInClasses.scala
Created August 25, 2017 12:38
Usage of spray json in Scala hierarchy of classes
import spray.json.JsonParser
val msg =
"""
| {"action":"move","data":{"direction":"left"}}
""".stripMargin
JsonParser(msg).asJsObject.getFields("action","data")(1).asJsObject.getFields("direction")
case class B(val afieldOfb: String)
@nachinius
nachinius / CMakeLists.txt
Last active October 20, 2016 20:07
max heapify in C
cmake_minimum_required(VERSION 3.6)
project(algC)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c")
set(SOURCE_FILES main.c)
add_executable(algC ${SOURCE_FILES})