Skip to content

Instantly share code, notes, and snippets.

View macournoyer's full-sized avatar

Marc-André Cournoyer macournoyer

View GitHub Profile
<!doctype html>
<html class="supports-no-js" lang="{{ request.locale.iso_code }}">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="theme-color" content="{{ settings.color_primary }}">
<link rel="canonical" href="{{ canonical_url }}">
{% if settings.favicon %}
/// A solver for Ruzzle (
/// Finds all the word combinations in a 4x4 grid of letters.
/// Requires a dictionnary (one word per line) in words.txt.
use std::collections::HashSet;
use std::fs::File;
use std::io::{self, BufReader};
use std::io::prelude::*;
const MIN_WORD_SIZE: usize = 5;
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
macournoyer / game.litcoffee
Last active April 14, 2017 23:44
JavaScript Game Basics in (Literate) CoffeeScript

The game we're building is a simple side-scrolling racing game. The player's car is static on the screen, only the background is moving. The enemies are planes whom the player must dodge using the up and down arrow keys. If the player hits a plane, he dies. One point is given each time a plane goes off screen without touching the player.


Our game is composed of sprites. Each sprite has a position (x, y), velocity (speed) and one image, or more if animated.

Images are loaded from the DOM using their CSS selector (imagesSelector). We use ID selectors (#name) for single images and class selectors (.name) for animated sprites composed of several images.

See the images used in the game.

macournoyer /
Created September 13, 2013 20:29
Sublime Text 2 RubyEval hack
import subprocess
import sublime, sublime_plugin
class EvalAsRuby:
def ruby(self):
return self.view.settings().get("ruby_eval").get("ruby")
except AttributeError:
return "ruby"
include Math;R1=1.0; R2=2.0;K2=5.0
SS=40;K1=SS*K2*3/(8*(R1+R2));def rf(a, b)
cosA=cos(a);sinA=sin(a);cosB=cos(b);sinB=sin(b){' ')};b=Array.
new(SS).fill{}; t=0.0;while t<2*PI
cost=cos(t);sint=sin(t);p=0.0;while p<2*PI;cosp=cos(p);sinp=
sin(p);cx=R2+R1*cost;cy=R1* sint;x=cx*(cosB*cosp+sinA*
sinB*sinp)-cy*cosA*sinB; y=cx*(sinB*cosp-sinA*##
cosB*sinp)+cy*cosA*cosB ;z=K2+cosA*cx*sinp+cy*
sinA;ooz=1/z;xp=(SS/2+K1* ooz*x).to_i ;yp= (SS/2-
macournoyer / Dockerfile
Last active December 14, 2019 16:31
Playing w/ Dockerfile on OS X
FROM base
MAINTAINER Marc-Andre Cournoyer ""
RUN apt-get -y update
RUN apt-get install -y -q curl
RUN curl -L | bash -s stable --ruby
RUN /bin/bash -l -c rvm requirements
macournoyer / abc.rb
Created November 5, 2012 17:16
First programming lesson w/ my 4yo daughter
alphabet = 'A'..'Z'
`say "#{alphabet.to_a.join(', ')}"`
class ModifyResponseHeaders
def initialize(app)
@app = app
def call(env)
status, headers, body =
headers["cache"] = "..."
[status, headers, body]