Skip to content

Instantly share code, notes, and snippets.

View jmbarbier's full-sized avatar

Jean-Matthieu BARBIER jmbarbier

View GitHub Profile
@maraujop
maraujop / forms.py
Created February 15, 2012 19:04
django-crispy-forms bootstrap form example
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
@ses4j
ses4j / incrementalmr.py
Created March 29, 2012 03:42
Periodically-updating pymongo/MongoDB incremental MapReduce example
def incremental_map_reduce(
map_f,
reduce_f,
db,
source_table_name,
target_table_name,
source_queued_date_field_name,
counter_table_name = "IncrementalMRCounters",
counter_key = None,
max_datetime = None,
@nblumoe
nblumoe / angularjs_resource_tokenhandler.js
Created July 5, 2012 07:34
AngularJS service to send auth token with $resource requests
.factory('TokenHandler', function() {
var tokenHandler = {};
var token = "none";
tokenHandler.set = function( newToken ) {
token = newToken;
};
tokenHandler.get = function() {
return token;
@jdp
jdp / Makefile
Created August 31, 2012 06:07
Use Makefiles for CoffeeScript, Handlebars, and Sass
COFFEEC = coffee
SASSC = sass
HANDLEBARSC = handlebars
# Build app package
APPSRC = static/scripts/main.coffee
APPOBJ = ${APPSRC:.coffee=.js}
APPOUT = static/scripts/app.js
@dhendo
dhendo / gist:4277592
Created December 13, 2012 16:21
Mongo Model Serializer for django-rest-framework
import mongoengine
class MongoModelSerializer(serializers.ModelSerializer):
def get_default_fields(self):
cls = self.opts.model
opts = get_concrete_model(cls)
#pk_field = opts.pk
fields = []
fields += [getattr(opts, field) for field in opts._fields]
#fields += [field for field in opts.many_to_many if field.serialize]
@niclashoyer
niclashoyer / literate_coffee_script.lang
Last active December 10, 2015 21:18
Syntax highlighting for Literate CoffeeScript in gtksourceview, e.g. gedit.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Author: Niclas Hoyer <niclas@verbugt.de>
Copyright (C) 2012 Niclas Hoyer <niclas@verbugt.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
@niwinz
niwinz / test.py
Created January 19, 2013 23:44
Support for patch method to django client.
from django.test import client
# Call this function on head of your test file.
def patch_request_factory():
def _method(self, path, data='', content_type='application/octet-stream', follow=False, **extra):
response = self.generic("PATCH", path, data, content_type, **extra)
if follow:
response = self._handle_redirects(response, **extra)
return response
@joshdmiller
joshdmiller / Gruntfile.js
Last active December 12, 2015 07:58
A Grunt 0.4 build system for modularized AngularJS projects.
/**
* A Boilerplate Grunt ~0.4.0 build system for AngularJS projects
*
* Licensed MIT
*/
module.exports = function ( grunt ) {
// Load required Grunt tasks
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-contrib-clean');
@Guigoz
Guigoz / SUBLIME TEXT 2 : keyboard shortcuts for AZERTY keyboards
Last active May 2, 2020 20:46
SUBLIME TEXT 2 : keyboard shortcuts for AZERTY keyboards
{ "keys": ["ctrl+œ"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{
"keys": ["super+alt+&"],
"command": "set_layout",
"args":
{
"cols": [0.0, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1]]
@thoop
thoop / nginx.conf
Last active December 8, 2023 21:55
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;