Skip to content

Instantly share code, notes, and snippets.

View m-renaud's full-sized avatar

Matt Renaud m-renaud

  • Google Inc.
  • San Francisco, CA
View GitHub Profile
@m-renaud
m-renaud / MatrixDemo.hs
Last active August 29, 2015 14:09
Simple Matrix addition in Haskell.
{-# LANGUAGE TemplateHaskell #-}
module MatrixDemo where
import Control.Lens
-- | Represents a matrix with the contents stored in row major order.
-- Note that we get equality, ability to read a Matrix from a stream
-- as well as write it to a stream for free by deriving (Eq,Read,Show).
data Matrix = Matrix { _numRows :: Int
, _numColumns :: Int
@m-renaud
m-renaud / basic-vimrc
Last active December 20, 2015 08:39
Basic Vim config.
" Turn on syntax highlighting...
syn on
" Turn on file type detection...
filetype on
filetype plugin indent on
" Set up default settings...
set autoindent
set expandtab
@m-renaud
m-renaud / basic-config.el
Created July 29, 2013 02:17
Basic Emacs configuration.
(setq make-backup-files nil)
(electric-indent-mode t)
(setq auto-save-interval 0)
(setq transient-mark-mode nil)
(setq visible-bell 1)
(iswitchb-mode 1)
(auto-compression-mode 1)
;; Give buffers unique names when there are 2 with the same name...
(require 'uniquify)
@m-renaud
m-renaud / signal-vs-sigaction.c
Last active December 20, 2015 08:39
signal() and sigaction()
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
void signal_handler_function(int signo);
typedef void (*sighandler_t)(int);
int main()
@m-renaud
m-renaud / eintr-handling.c
Last active April 5, 2018 04:49
EINTR handling.
// Examples of EINTR handling for reentrant functions.
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//m=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Open can be interupted when blocked, waiting for a slow device such as a
@m-renaud
m-renaud / process.php
Last active December 14, 2015 00:29
Validate a form using php.
<?php
session_start();
header("Content-Type: text/html");
$errors = array();
// Reset form.
if(array_key_exists('clearForm', $_POST))
{
unset($_SESSION);