Skip to content

Instantly share code, notes, and snippets.

View PhDP's full-sized avatar
🏠
Working from home

Philippe Desjardins-Proulx PhDP

🏠
Working from home
View GitHub Profile
@PhDP
PhDP / foo.html
Created February 8, 2014 18:00
A simple html file for testing a regex.
<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<body>
<div class="x">
<div id="y">
<p>This is some <b>nice</b> <i>text</i>, right?</p>
<P>This is some nice text, right?</P>
</div>
<P class="Some text" id="xyz">
<u>This</u> is some nice text, right?
@PhDP
PhDP / gist:9012512
Created February 15, 2014 00:35
Text for web requests.
<html>Test</html>
@PhDP
PhDP / gist:11275427
Created April 25, 2014 01:47
For testing...
<html>
<section>
<p>AAA</p>
</section>
<p>BBB</P>
<P id='z'>CCC</p>
<div>
<p>DDD</p>
<div>
<p>EEE</p>

This is my recommended path for learning Haskell.

Something to keep in mind: don't sweat the stuff you don't understand immediately. Just keep moving.

Primary course

Installing Haskell

Ubuntu PPA

@PhDP
PhDP / rounding.py
Created May 22, 2014 19:01
Why directional rounding is odd. Try with python2 (rounds ties away from zero, which is bad) and python3 (rounds ties to nearest even number).
from random import randint as rand
max = 10000000
sum = 0
sumR = 0
for i in range(0, max):
x = rand(1, 1000) / 2.0
sum += x
sumR += round(x)
print((sumR - sum) / max)
@PhDP
PhDP / mcpi.c
Created July 28, 2014 17:21
randamu example
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <randamu/rng.h>
int main() {
const clock_t start = clock();
rd_rng r; // A random number generator.
rd_rng_init_time(&r); // Initialize with the current time.
const int max = 2000000000;
@PhDP
PhDP / debug.h
Last active August 29, 2015 14:04
Debug macros
// From: http://c.learncodethehardway.org/book/ex20.html
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
@PhDP
PhDP / appveyor.yml
Created August 21, 2014 04:24
appveyor.yml for windows (untested)
os: Windows Server 2012
platform: x64
branches:
only:
- master
install:
- cinst cmake
- cinst make

Keybase proof

I hereby claim:

  • I am phdp on github.
  • I am phdp (https://keybase.io/phdp) on keybase.
  • I have a public key whose fingerprint is 081D 2E96 EC38 85A1 4E50 5C8C 9FA9 BB43 2964 5021

To claim this, I am signing this object:

@PhDP
PhDP / vecadd.c
Created December 8, 2014 13:12
Simple opencl exaple. It works on UNIX but fails on Windows with NVIDIA drivers for some reason.
// From Gaster et al.'s "Heterogeneous Computing with OpenCL".
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenCL/OpenCL.h>
#else
#include <CL/cl.h>