Skip to content

Instantly share code, notes, and snippets.

View cloderic's full-sized avatar

Clodéric Mars cloderic

View GitHub Profile
@cloderic
cloderic / markdown.js
Created March 20, 2020 09:47
Markdown React Component
import Link from './link';
import markdown from 'remark-parse';
import React from 'react';
import rehype2react from 'rehype-react';
import remark2rehype from 'remark-rehype';
import unified from 'unified';
// Let's create a markdown compiler using unified
// -- cf. https://github.com/unifiedjs/unified
const processor = unified()
@cloderic
cloderic / got_families.csv
Created August 29, 2019 11:37
GOT families
parent_name parent_sex child_name child_sex
Rickard Stark M Eddard Stark M
Rickard Stark M Brandon Stark M
Rickard Stark M Benjen Stark M
Eddard Stark M Jon Snow M
Eddard Stark M Robb Stark M
Eddard Stark M Sansa Stark F
Eddard Stark M Arya Stark F
Eddard Stark M Bran Stark M
Eddard Stark M Rickon Stark M
@cloderic
cloderic / naive_prime_factors_decomposition.py
Created December 12, 2018 15:38
Naive Prime Factors Decomposition
# Returns true if n is a prime number
def check_prime(n):
x = 2
while(x < n):
if n % x == 0:
# Factor other then 1 or n, number is composite
return False
x = x +1
# Number is prime, while loop terminated without finding factor
return True
@cloderic
cloderic / git_publish.py
Created August 13, 2015 14:21
Script to publish the content of a directory to git (useful for gh-pages)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import subprocess
import os
import shutil
import sys
import datetime
@cloderic
cloderic / add_to_ssh_known_hosts.sh
Created June 1, 2015 09:45
Add host to ssh `known_hosts` file
#!/bin/bash
host=$1
echo "Adding $host to the ssh known hosts..."
ssh-keyscan -t rsa,dsa $host 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts
cat ~/.ssh/tmp_hosts >> ~/.ssh/known_hosts
@cloderic
cloderic / docker_cheat_sheet.md
Last active August 8, 2018 13:05
Useful docker scripts

Docker Cheat Sheet

Images and Containers garbage collection

Just use Spotify's garbage collector by simply running

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock spotify/docker-gc
@cloderic
cloderic / Steering.py
Created February 8, 2014 12:58
Steering agents in Pythonista
from scene import *
from collections import namedtuple
import copy
import random
class Vector2:
def __init__(self, x = 0.0, y = 0.0):
self.x = x
self.y = y
@cloderic
cloderic / tiny_httpd.py
Last active December 16, 2015 09:09
Tiny HTTP server in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2013 Clodéric Mars <cloderic.mars@masagroup.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
@cloderic
cloderic / Cocos2dxConfig.cmake.in
Last active December 12, 2015 07:48
cocos2d-x SDK extraction
### Cocos2dx package configuration ###
# This module configure the cocos2dx libs.
#
# WARNING: This is not supposed to be a full fledged configuration file,
# it just supports our current needs
#
# It defines the following:
# - COCOS2DX_INCLUDE_DIRS (include directories);
# - The imported target libcocos2d (shared library);
# - COCOS2DX_DLLS_RELEASE (if WIN32 - all needed release dlls);
@cloderic
cloderic / gist:2895696
Created June 8, 2012 13:48
get/set/touch
class A
{
public:
const B& getB() const
{
return _myB;
}
void setB(const B& newB) const
{
_myB = newB;