Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>
int main(void) {
int errorno = wiringPiSetupGpio();
// No newline, so I missed this a few times
// debugging when it was the line above and this line only
// it gets instered before the prompt when the program finishes.
printf("Plpo");
#include "FIFO.h"
#include "common.h"
#define AccessBuffer(buffer, index, index_width) ((char *)(buffer))+((index) * (index_width))
int FIFO_Init(FIFOBuffer_TypeDef *buf, uint32_t maxSize, uint32_t bufferWidth, void *buffer) {
if (!buffer) {
return -1;
}
@matthewphilyaw
matthewphilyaw / fixtures.ex
Last active December 31, 2015 17:09
Proposal for testing
defmodule Yggdrasil.Fixtures do
@moduledoc """
A module for fixtures for various tests
"""
def user do
quote do
@min_len 4
@password "password"
@short_password String.slice(@password, 1..(@min_len - 1))
@matthewphilyaw
matthewphilyaw / Maybe2.cs
Created December 27, 2015 16:37
Maybe Monad take 2
using System;
namespace Maybe
{
abstract class Maybe<T> {
public static Maybe<T> Return(T val)
{
return new Just<T> (val);
}
open System
type Maybe<'a> =
| Just of 'a
| Nothing
let Unit (x: 'a) : Maybe<'a> =
Just x
let Bind (f: 'a -> Maybe<'b>) (mx: Maybe<'a>) =
@matthewphilyaw
matthewphilyaw / Maybe.cs
Last active December 26, 2015 20:29
Maybe monad in C#
using System;
namespace Maybe
{
interface Maybe<T>
{
T Value();
bool HasValue();
Maybe<T> Bind(Func<T, Maybe<T>> f);
}
@matthewphilyaw
matthewphilyaw / convertolist.ex
Last active August 29, 2015 14:20
Elixir bit syntax example
speed = 500
angle = -200
# being very explicit here, I believe the default
# unit is 8, and the endianess is big
#
# So I do need to pack this message in particular way according to the
# specs for the roomba serial interface, which is the like this
#
# command [optional bytes]
define("app/templates/application", ["exports"], function(__exports__){ __exports__["default"] = function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
var buffer = '', stack1, helper, options, self=this, helperMissing=helpers.helperMissing;
function program1(depth0,data) {
data.buffer.push("Builder");
}
// these two are taken from the docs
struct Point {
x: f64,
y: f64
}
// They use shape later in the docs to show pattern matching
// but I'm going to attempt to explain it
@matthewphilyaw
matthewphilyaw / fmt.rs
Created March 18, 2014 11:05
use of traits
use std::fmt;
struct Name {
first: ~str,
last: ~str
}
// I'm printing a string here, but
// in reality this could be binary output
impl fmt::Binary for Name {