Skip to content

Instantly share code, notes, and snippets.

View maximebf's full-sized avatar

Maxime Bouroumeau-Fuseau maximebf

View GitHub Profile
### Keybase proof
I hereby claim:
* I am maximebf on github.
* I am maximebf (https://keybase.io/maximebf) on keybase.
* I have a public key whose fingerprint is 6406 AD6C BB97 BE07 6B87 C7B3 682E 2EB1 7598 80E1
To claim this, I am signing this object:
@maximebf
maximebf / mgitstatus
Last active August 29, 2015 14:07
mgitstatus
#!/bin/bash
# Display the status of all git directories in the current directory
show() {
cd $1
branch=`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\\\\\1/`
if [ -n "`git status 2> /dev/null | grep 'nothing to commit'`" ]; then
status="\e[32mok\e[0m"
else
status="\e[31mmodified\e[0m"
@maximebf
maximebf / config_files.rb
Last active February 19, 2016 08:26
Plugins, configuration files and fabfile to help you manage a multi-site jekyll setup
module Jekyll
class Site
def read
self.read_config
self.read_layouts
self.read_directories
end
def read_config(dir='')
@maximebf
maximebf / fabfile.py
Last active December 19, 2015 17:38
Fabfile to publish jekyll blogs with supervisor and nginx configuration
from fabric.api import task, env, execute, local
env.build_path = '/tmp/jekyll'
env.publish_path = '~/sites'
@task
def serve(future='yes', drafts='yes', port=4000):
flags = []
@maximebf
maximebf / drafts.rb
Created November 24, 2012 18:19
Draft plugin for jekyll
# Search for posts in _drafts folder
#
# Add "drafts: true" in your config file to
# activate the plugin
#
# Filenames should not have a date
# eg: _drafts/my-future-posts.md
#
# Draft posts will have a post.draft property
#
@maximebf
maximebf / gist:3986659
Created October 31, 2012 11:56
Jinja2 macro to render WTForms fields with Twitter Bootstrap
{% macro form_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="control-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}:
@maximebf
maximebf / gist:3986583
Created October 31, 2012 11:36
Add dynamic subdomain support to a Flask app
def add_subdomain_to_global(endpoint, values):
g.subdomain = values.pop('subdomain', None)
def add_subdomain_to_url_params(endpoint, values):
if not 'subdomain' in values:
values['subdomain'] = g.subdomain
def add_subdomain_support(app):
app.url_value_preprocessor(add_subdomain_to_global)
app.url_defaults(add_subdomain_to_url_params)
@maximebf
maximebf / ratp.py
Created August 4, 2012 10:42
Small Flask app that exposes an API to query French's RATP schedule
#!/usr/bin/env python
# coding: utf-8
from flask import Flask, request, jsonify
import urllib2
from BeautifulSoup import BeautifulSoup
app = Flask(__name__)
@maximebf
maximebf / fabfile.py
Created February 5, 2012 22:27
Fabfile to deploy a jekyll site
from fabric.api import task, run, env, execute, local, put, lcd
env.site_path = '/tmp/jekyll-site'
env.tar_filename = env.site_path + '.tar.bz2'
env.remote_site_path = '~/public_html'
@task
def build():
local("jekyll %s" % env.site_path)
@maximebf
maximebf / webtail.py
Created October 21, 2011 13:25
Web tail / tail -f as a webpage using websocket
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver