Skip to content

Instantly share code, notes, and snippets.

@levinotik
levinotik / trace.log
Created November 1, 2022 04:07
pyenv install trace log
+(/Users/levinotik/.pyenv/bin/pyenv:23): enable -f /Users/levinotik/.pyenv/bin/../libexec/pyenv-realpath.dylib realpath
+(/Users/levinotik/.pyenv/bin/pyenv:58): '[' -z /Users/levinotik/.pyenv ']'
+(/Users/levinotik/.pyenv/bin/pyenv:61): PYENV_ROOT=/Users/levinotik/.pyenv
+(/Users/levinotik/.pyenv/bin/pyenv:63): export PYENV_ROOT
+(/Users/levinotik/.pyenv/bin/pyenv:65): '[' -z '' ']'
+(/Users/levinotik/.pyenv/bin/pyenv:66): PYENV_DIR=/Users/levinotik/dev/carson/api-load-testing
+(/Users/levinotik/.pyenv/bin/pyenv:69): '[' '!' -d /Users/levinotik/dev/carson/api-load-testing ']'
+(/Users/levinotik/.pyenv/bin/pyenv:69): '[' '!' -e /Users/levinotik/dev/carson/api-load-testing ']'
++(/Users/levinotik/.pyenv/bin/pyenv:73): cd /Users/levinotik/dev/carson/api-load-testing
++(/Users/levinotik/.pyenv/bin/pyenv:73): echo /Users/levinotik/dev/carson/api-load-testing
class Counter(val count: Int = 0) {
def inc = new Counter(count + 1)
def dec = new Counter(count - 1)
}
@levinotik
levinotik / GrasswireUrlShortener.scala
Created August 7, 2014 05:45
prototype of a URL shortener
package com.grasswire.grasswireurlshortener
import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory
import org.apache.commons.validator.routines.UrlValidator
import spray.http.StatusCodes
import spray.routing._
import scala.util.Random
import scalaz.concurrent._
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
sudo apt-get install python3-setuptools
sudo easy_install3 pip # will be a Python3 pip
sudo pip install virtualenv # will be py3

An expression is said to be referentially transparent if it can be replaced with its value without changing the behavior of a program (in other words, yielding a program that has the same effects and output on the same input)

https://en.wikipedia.org/wiki/Referential_transparency

This example is taken from the book "Functional Programming in Scala"

The following is referentially transparent:

scala> val x = "hello, world"
@levinotik
levinotik / playground.rs
Created April 10, 2016 21:05 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
// No good because we move v to v2
// which creates a copy of the pointer
// which means we have two pointers
// to the content of the vector on the heap
// this violates safety guarantees
// by introducing a data race
// therefore Rust forbids using v after the move
@levinotik
levinotik / Folds.hs
Created January 19, 2016 02:31
Explicit recursion vs Folding
module Folding where
import Prelude hiding (length, sum, maximum, elem, null, product, reverse, all, any, (++), map, init, filter)
sum :: Num a => [a] -> a
sum [] = 0
sum (x:xs) = x + sum xs
sum' :: Num a => [a] -> a
sum' = foldl (+) 0
package com.film42.forecastioapi
import com.eclipsesource.json.JsonObject
import java.net.URL
import java.util.{Date, Scanner}
import spray.json._
import model.ForecastJsonProtocol._
import model._
import scala.util.{Success, Try}