Skip to content

Instantly share code, notes, and snippets.

View stephane's full-sized avatar
🎯
Focusing

Stéphane Raimbault stephane

🎯
Focusing
View GitHub Profile
@stephane
stephane / gist:5e614da08649e59ef3c6
Created February 25, 2015 17:40
Duplicate lines
(defun duplicate-current-line-or-region (arg)
"Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated. However, if
there's a region, all lines that region covers will be duplicated."
(interactive "p")
(let (beg end (origin (point)))
(if (and mark-active (> (point) (mark)))
(exchange-point-and-mark))
(setq beg (line-beginning-position))
(if mark-active
@stephane
stephane / libsoup and Django
Last active August 29, 2015 14:15
Interface Django with C code with libsoup
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <libsoup/soup.h>
#include <libsoup/soup-auth.h>
static char* django_get_csrftoken_from_body(SoupMessage *msg)
{
@stephane
stephane / Makefile
Created May 14, 2014 14:22
Makefile target to generate PO file from POT (angular-gettext)
makemessagesjs:
grunt nggettext_extract; \
export PO_FILE=locale/fr/LC_MESSAGES/angular.po; \
export POT_FILE=$${PO_FILE}t; \
[ ! -f $$PO_FILE ] && msginit -i $$POT_FILE -o $$PO_FILE || msgmerge --update $$PO_FILE $$POT_FILE; \
rm $$POT_FILE;
@stephane
stephane / Gruntfile.js
Created May 14, 2014 14:20
Grunt task to extract and compile PO files
/* global module */
module.exports = function(grunt) {
'use strict';
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.initConfig({
nggettext_extract: {
ops: {
@stephane
stephane / gist:5450978
Created April 24, 2013 09:39
Avoid multiple clicks on same DOM object and reactivates it after 5 seconds.
function disable_a_moment(o) {
o.disabled = true;
o.value = o.value + "…";
setTimeout(function() {
o.disabled = false;
o.value = o.value.substr(0, o.value.length - 1);
}, 5000);
}