Skip to content

Instantly share code, notes, and snippets.

@sashaafm
sashaafm / erlang_formats.erl
Created October 4, 2016 13:07
Example on how to get all Erlang formats from source code to disassembled bytecode
% Example on how to get all Erlang formats from source code to disassembled bytecode
% Erlang Source --> Erlang AST --> Erlang Expanded AST --> Core Erlang --> BEAM Bytecode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% First the original module
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(add).
-export([add/2]).
@matthieubulte
matthieubulte / Leibniz.purs
Last active August 30, 2016 11:41
Foundations for proving stuff in PureScript
{-
A bunch of useful primitives when using PureScript to prove *things*.
Idea of using Leibniz equality comes from http://code.slipthrough.net/2016/08/10/approximating-gadts-in-purescript/
-}
module Leibniz where
import Prelude ((<<<), ($))
import Unsafe.Coerce (unsafeCoerce)
@dariooddenino
dariooddenino / post.purs
Created July 29, 2016 16:17
post request
data Post = Post { id :: Maybe Int
, title :: String
, body :: String
, userId :: Int
}
instance decodeJsonPost :: DecodeJson Post where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
anonymous
anonymous / index.html
Created July 7, 2016 18:50
JS Bin // source http://jsbin.com/jozihiluki
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://wzrd.in/standalone/reduce-reducers"></script>
<style id="jsbin-css">
#tabs span {
anonymous
anonymous / index.html
Created July 6, 2016 19:10
JS Bin // source http://jsbin.com/jozihiluki
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://wzrd.in/standalone/redux-watch"></script>
<style id="jsbin-css">
#tabs span {
anonymous
anonymous / index.html
Created July 6, 2016 17:42
JS Bin // source http://jsbin.com/jozihiluki
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://wzrd.in/standalone/deep-freeze"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<style>
anonymous
anonymous / index.html
Created July 6, 2016 16:53
JS Bin // source http://jsbin.com/jozihiluki
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://wzrd.in/standalone/deep-freeze"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<style>
anonymous
anonymous / index.html
Created July 5, 2016 18:23
JS Bin // source http://jsbin.com/mexenebaku
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.min.js"></script>
<script src="https://wzrd.in/standalone/deep-freeze"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.min.js"></script>
</head>
@ttsiodras
ttsiodras / RustyThoughts.md
Last active September 8, 2020 08:17
Rusty thoughts on affine types

Below is my understanding of affine types and how they help us in Rust (unsure if I got this right - please correct if I am talking nonsense).

The issue is... How can we use the power of a type system so a compiler will block us from doing this wrong sequence of calls?

FILE *fp = NULL;
fclose(fp);
fp = fopen("...");

An idea is to "mirror" the states that the file variable goes through (unused/closed, opened) in the type system:

@AlexMoffat
AlexMoffat / display_on.sh
Last active September 5, 2022 16:23
raspberry pi turn on hdmi connected display. Use fbset -s to find the current values for xres and yres. You need to make some change to the fb values before the refresh call or nothing happens.
#!/bin/bash
set -o pipefail
tvservice -s | grep -q '\[TV is off\]'
if [[ $? -eq 0 ]]; then
# Turn display on.
/usr/bin/tvservice -p &> /dev/null
# Change color depth to 8 and back to 16.
/bin/fbset -xres 1920 -yres 1200 -depth 8
/bin/fbset -xres 1920 -yres 1200 -depth 16
# Now that something has changed refresh.