Skip to content

Instantly share code, notes, and snippets.

View m-r-r's full-sized avatar

Mickaël RAYBAUD-ROIG m-r-r

View GitHub Profile
@m-r-r
m-r-r / Advent of code 2017 — Day 2.js
Created December 8, 2017 22:00
Advent of code 2017 — Day 2
// http://adventofcode.com/2017/day/2
// Parse the input into a two-dimensional array of numbers
const parseSpreadsheetRow = input => input.split(/\s+/).map(n => parseInt(n));
const parseSpreadsheet = input => input.split('\n').map(parseSpreadsheetRow);
// Find the highest and lowest values in a list
const max = values =>
values.reduce((previous, current) => Math.max(previous, current));
const min = values =>
@m-r-r
m-r-r / Advent of code 2017 — Day 1.js
Last active December 8, 2017 22:01
Advent of code 2017 — Day 1
// http://adventofcode.com/2017/day/1
// Sums the digits matching the next digit.
// The list is circular: is the first and last digits are the same, the last digit matches.
const sumMatchesNext = input =>
Array.from(String(input)) // Turn the input into an array of characters
.map(Number) // Turn the caracters into number
.reduce((sum, digit, i, digits) => {
const index = (i + 1) % digits.length; // The list is circular
// If the digit is the same as the next digit, add it to the sum
@m-r-r
m-r-r / playground.rs
Created February 27, 2017 12:20 — forked from anonymous/playground.rs
Shared via Rust Playground
type Freq = f32;
#[derive(Clone, Debug)]
pub struct Note(u8, u8, Freq);
impl Note {
pub fn number(&self) -> u8 {
self.0
}
@m-r-r
m-r-r / index.html
Created November 25, 2015 11:25 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/pehagezesu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.separator {
display: block;
width: 100%;
font-weight: 400;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
(function () {
"use strict";
@m-r-r
m-r-r / keybase.md
Created April 16, 2015 22:15
keybase.md

Keybase proof

I hereby claim:

  • I am m-r-r on github.
  • I am mrr (https://keybase.io/mrr) on keybase.
  • I have a public key whose fingerprint is 5A67 EC9B 8B23 B53D 6697 338B 5E77 1384 CC52 82E8

To claim this, I am signing this object:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src='http://cdn.ractivejs.org/latest/ractive.js'></script>
<script src='http://cdn.jsdelivr.net/ractive.adaptors-backbone/latest/ractive-adaptors-backbone.min.js'></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<script id="app-template" type="text/ractive">
<header id="header">
@m-r-r
m-r-r / math.fish
Last active August 29, 2015 14:06
A Fish function for doing floating points calculations
function math --description 'Perform math calculations in bc'
if count $argv > /dev/null
switch $argv[1]
case -h --h --he --hel --help
__fish_print_help math
return 0
end
set -lx LC_NUMERIC C
set -lx BC_LINE_LENGTH 0
set -l out (echo $argv | bc)
@m-r-r
m-r-r / archives.html
Created July 19, 2012 14:40
Modification du thème bootstrap2 pour Pelican
{% extends "base.html" %}
{% block content %}
<section id="content">
<h1>Archives for {{ SITENAME }}</h1>
<dl>
{% for article in articles %}
{% if loop.first or article.date.strftime('%Y %m') != articles[loop.index0-1].date.strftime('%Y %m') %}
<dt>
<h2>{{ article.date.strftime('%B %Y') }}</h2>
<ul>