Skip to content

Instantly share code, notes, and snippets.

Christian Oudard christian-oudard

Block or report user

Report or block christian-oudard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Please publicly post the following Gist, and name it

Keybase proof

I hereby claim:

  • I am christian-oudard on github.
  • I am christianoudard ( on keybase.
  • I have a public key ASDUW30p7kTHKwf_VGcYiMCC_iPMzpJVFihxm4EGJG3_Gwo
View gist:16eaeeffa2a1b1004f75
import Data.List.Zipper as Z
main = do
let string = "yabbadabbadoo"
print $ maximum $ palindromeSizes string
-- Find the size of the largest palindrome centered at each location in
-- a string. There will be 2*n-1 locations, because we count even and odd
-- centers. Go along the zipper, checking the sizes of palindromes to the left
-- and right as we go.
christian-oudard /
Created Feb 8, 2012
Luhn validation algorithm for credit cards.
Python implementation of the Luhn algorithm.
Refer to:
>>> is_luhn_valid(79927398713)
>>> is_luhn_valid(79927398714)
>>> is_luhn_valid(4532990475689429)
christian-oudard / palindromes
Created Mar 15, 2011
Palindrome number investigations
View palindromes
def digits_of(n, base=10):
Split the number into its digits.
>>> digits_of(0)
>>> digits_of(123)
[1, 2, 3]
>>> digits_of(0xabc, base=16)
[10, 11, 12]
christian-oudard /
Created Jun 29, 2010
Github Flavored Markdown in Python
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(
extractions[digest] =
return "{gfm-extraction-%s}" % digest
View python flatten
Flatten a nested list structure.
* Works for nested structures of lists, tuples, generators, or any other iterable.
* Special-cases string types and treats them as non-iterable.
* Is not limited to the system recursion limit.
* Yields items from the structure instead of constructing a new list, and can
work on non-terminating generators.
This is basically a non-recursive version of the following:
View hudson fabric deploy bash script
if [ ! -z "$WORKSPACE" ]; then
christian-oudard /
Created Oct 28, 2009
Terminal output colors in python
from __future__ import print_function
Utilities for 256 color support in terminals.
Adapted from:
The color palette is indexed as follows:
0-15: System colors
You can’t perform that action at this time.