Skip to content

Instantly share code, notes, and snippets.

@ringvold
ringvold / oled.mdlive
Created September 20, 2022 22:08
Basic setup for working with oled with nerves (SSD1306 128x32)
# OLED
```elixir
Mix.install([
:oled,
:chisel
])
```
## Basic setup
@ringvold
ringvold / bmp280.livemd
Created September 20, 2022 20:31
Livebook notebook for interacting with the bmp280 sensor

BMP280 temperatur sensor

Introduction

This is a simplified version Masatoshi Nishiguchi's bmp280.livemd notebook that's included in Nerves Livebook. Check out that notebook if you'd like to try this out yourself.

Setup

BMP280

Mix.install([
  {:kino, "~> 0.6.1"},
  {:kino_vega_lite, "~> 0.1.1"}
])

alias VegaLite, as: Vl
sudo dpkg --add-architecture i386; sudo apt update; sudo apt install mailutils postfix curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc jq tmux lib32gcc1 libstdc++6 libstdc++6:i386
wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh csgoserver
./csgoserver auto-install
echo "This script uses these environment variables \n that are to be set by the user: "
echo "- LGSM_SERVER_IP"
echo "- RCON_PASSWORD"
echo "- GSLT_TOKEN"
echo "- CSGO_SERVER_PASSWORD"
@ringvold
ringvold / functors.md
Last active December 12, 2019 22:03
Functors - What are they?

Functors - What are they?

In this article we will be looking at a concept in FP called functor.

A functor might sound very strange and esoteric but chances are you have used it in some ways. Some of you probably a lot! In this article we will look at what they are and some reasons they are usefull.

Lets start with a definition of a functor and then try to make sense of it. This will not be a comprehensive explanation and we will be glossing over some details for in the interest of brevity but it will hopefully be enough you get you started.

"A functor is a structure with one (or more) values in it that has a function that can transform the value".

require "date"
require "json"
def log_to_hash
commits = []
res = %x(git log --date=iso --pretty=format:'{\"short_hash\":\"%h\",\"name\":\"%an\",\"email\":\"%ae\",\"date\":\"%ad\",\"subject\":\"%s\"}')
res.each_line do |line|
commits << JSON.parse(line, {symbolize_names: true})
end
return commits

Keybase proof

I hereby claim:

  • I am ringvold on github.
  • I am ringvold (https://keybase.io/ringvold) on keybase.
  • I have a public key ASBr7yMRZ7vDDOxC0D8MgpPMJiGvo8HqoUQFCLDN0NEatAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am haraldringvold on github.
  • I am haraldringvold (https://keybase.io/haraldringvold) on keybase.
  • I have a public key whose fingerprint is EC28 0A40 44BD 2EFF 5E9F 4454 61A6 FFD7 A33A 08EF

To claim this, I am signing this object:

@ringvold
ringvold / designer.html
Created August 22, 2014 14:20
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
/* Foundation 5 Revised Grid + custom push/pull resets */
.row {
margin-left: auto;
margin-right: auto;
margin-top: 0;
margin-bottom: 0;
max-width: 62.5em;
width: 100%;
*zoom: 1; }
.row:before, .row:after {