Skip to content

Instantly share code, notes, and snippets.

@dariosalvi78
dariosalvi78 / ADS1256.c
Last active December 21, 2023 08:23
Simple library for ADS1256 to be used with Arduino. It does not implement the whole set of features, but can be used as a starting point for a more comprehensive library.
/* ADS1256 simple library for Arduino
ADS1256, datasheet: http://www.ti.com/lit/ds/sbas288j/sbas288j.pdf
connections to Atmega328 (UNO)
CLK - pin 13
DIN - pin 11 (MOSI)
DOUT - pin 12 (MISO)
CS - pin 10
DRDY - pin 9
RESET- pin 8 (or tie HIGH?)
@non
non / laws.md
Last active February 20, 2022 00:26
I feel like conversations around laws and lawfulness in Scala are often not productive, due to a lack of rigor involved. I wanted to try to be as clear and specific as possible about my views of lawful (and unlawful) behavior, and what I consider a correct and rigorous way to think about laws (and their limits) in Scala.

Laws

A law is a group of two or more expressions which are required to be the same. The expressions will usually involve one or more typed holes ("inputs") which vary.

Some examples:

x.map(id) === x

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 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
@hfreire
hfreire / rpi-usb.sh
Last active July 24, 2019 17:39
Enable/disable power on Raspberry Pi USB ports + Ethernet
#!/bin/sh
SOC_USB=/sys/devices/platform/soc/20980000.usb
if [ ! -d $SOC_USB ];
then
SOC_USB=/sys/devices/platform/soc/3f980000.usb # Raspberry Pi 3
fi
BUSPOWER=$SOC_USB/buspower
@yellowflash
yellowflash / RegExp.scala
Last active September 1, 2018 01:06
Regex Engine which runs in `O(mn)` Glushkov automaton
sealed trait RegExp {
def isFinal:Boolean
def acceptsEmpty:Boolean
def shift(prev:Boolean, character:Char):RegExp
def matches(str:String) =
if(str.isEmpty) this.acceptsEmpty
else str.foldLeft(this.shift(true, str.head))(_.shift(false,_)).isFinal
}
object Epsilon extends RegExp {
String.format() call with mismatched args
Unused function argument
aList.length == 0 <- use .isEmpty
Using string interpolation unnecessarily
Calling .toString on Array
Close scala.io.Source
Inferring Nothing
Casting instead of .toByte
Calling .toSeq on a Seq
Calling .toString on a String
@jrudolph
jrudolph / analysis.txt
Last active May 21, 2019 12:42
Scala 2.11 Release Train
TargetVersion: Scala 2.11 LastVersion: Scala 2.10
86 libraries available for Scala 2.11 (see the end for sbt config lines)
akka-actor 80 versions: 2.5.9, 2.5.8, 2.5.7, 2.5.6, 2.5.5, ... [75 more]
akka-stream 57 versions: 2.5.9, 2.5.8, 2.5.7, 2.5.6, 2.5.5, ... [52 more]
akka-http-core 51 versions: 3.0.0-RC1, 2.4.9, 2.4.9-RC2, 2.4.9-RC1, 2.4.8, ... [46 more]
akka-http 29 versions: 3.0.0-RC1, 10.1.8, 10.1.7, 10.1.6, 10.1.5, ... [24 more]
akka-osgi 80 versions: 2.5.9, 2.5.8, 2.5.7, 2.5.6, 2.5.5, ... [75 more]
akka-slf4j 80 versions: 2.5.9, 2.5.8, 2.5.7, 2.5.6, 2.5.5, ... [75 more]
akka-testkit 80 versions: 2.5.9, 2.5.8, 2.5.7, 2.5.6, 2.5.5, ... [75 more]
@edofic
edofic / compiler.scala
Created July 11, 2013 12:26
scala runtime compilation
val compile = {
import tools.reflect.ToolBox
val c = reflect.runtime.currentMirror
val tb = c.mkToolBox()
(src: String) => tb compile (tb parse (imports+src))
}
@travisbrown
travisbrown / noncompilation.scala
Last active January 13, 2016 18:00
Testing for compiler errors with untyped macros.
scala> import scala.language.experimental.macros
import scala.language.experimental.macros
scala> import scala.reflect.macros.{ Context, TypecheckException }
import scala.reflect.macros.{Context, TypecheckException}
scala> object NoncompilationTests {
| def compiles(code: _): Boolean = macro compiles_impl
| def compiles_impl(c: Context)(code: c.Tree) = c.literal(
| try {