Skip to content

Instantly share code, notes, and snippets.

View Natim's full-sized avatar
🏠
Working from home

Rémy HUBSCHER Natim

🏠
Working from home
  • Silvr
  • Rennes
  • 16:27 (UTC +02:00)
  • X @Natim
View GitHub Profile
@Natim
Natim / .emacs
Last active October 9, 2015 05:38
Emacs configuration
;; Ici on parle UTF-8
(set-language-environment "UTF-8")
;; Fichier de Customize
(setq custom-file "~/.emacs-custom.el")
(load custom-file)
;; On supprime ce qui est inutile (Barre d'outils, scroll)
(menu-bar-mode nil)
(tool-bar-mode -1)
@Natim
Natim / email_cleaner.py
Created August 10, 2012 21:49
Extract email from a file, make them unique and sort them.
import re, sys
email_pattern = re.compile('([\w\-\.]+@(\w[\w\-]+\.)+[\w\-]+)')
email_list = []
for line in sys.stdin:
# there are several matches per line
for match in email_pattern.findall(line):
email = match[0].lower()
@Natim
Natim / models.py
Created June 28, 2012 09:37
Django French Phone Template Tag
from intranet.widgets import PhoneField
class Restaurant(models.Model):
phone = PhoneField(_(u'Téléphone de réservation'), help_text=_(u"Veuillez entrer votre numéro sous la forme : 03 90 87 65 43 ou +33.390876543"))
@Natim
Natim / directory tree
Created June 7, 2012 12:54
Getting started with CouchdbKit
greetings/
├── _design
│   └── greetings
│   └── views
│   └── all
│   └── map.js
└── greetings.py
4 directories, 2 files
@Natim
Natim / backends.py
Created April 19, 2012 15:41
ObjectPermission in Django
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User, AnonymousUser
from django.utils.importlib import import_module
class ObjectPermissionBackend(object):
supports_object_permissions = True
supports_anonymous_user = True
supports_inactive_user = True
@Natim
Natim / gist:2420717
Created April 19, 2012 12:34
Django UploadFile
def upload_to_valid_name(prefix_dir):
''' Create the right function '''
def get_valid_name(instance, name):
from django.template.defaultfilters import slugify
from django.utils.encoding import smart_str
import os
n = name.rsplit('.',1)[0]
ext = name.rsplit('.',1)[1]
n = smart_str(slugify(n).replace('-', '_'))
@Natim
Natim / Document.xlsm
Created April 7, 2012 20:48
Web Browser Back Button in VBA for Office Excel - history.go(-1) in Excel
Option Explicit
Dim History As New Collection
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim wksht As Worksheet
Set wksht = Sh
History.Add wksht
If History.Count > 10 Then History.Remove 1
End Sub
@Natim
Natim / client.js
Last active August 29, 2015 14:21 — forked from timothylhuillier/client.js
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
//var testMessage = "[hello world] pid: " + process.pid;
var message = new Buffer([0x65,
'I', 'P', 'A', 'D', 0x00,
'N','A', 'M', 'E', 0x00,
'J', 'S', 'O', 'N', 0x00,
'V', 'E', 'R', 'S', 0x00,
'U', 'U', 'I', 'D', 0x00,
@Natim
Natim / keybase.md
Created May 11, 2015 10:18
keybase.md

Keybase proof

I hereby claim:

  • I am Natim on github.
  • I am natim (https://keybase.io/natim) on keybase.
  • I have a public key whose fingerprint is 6EE7 90DE 2D5B 88AA F079 11BC A500 E24B 9540 5094

To claim this, I am signing this object:

@Natim
Natim / README.md
Created February 2, 2015 11:03
How to get an Oauth token for an client side app?

One of the problem when doing full HTML5 apps is the Authentication.

With Firefox Account, the OAuth dance implies a server. Here are some tips that we are using to provide the Oauth token to the client app after the Oauth dance.

  1. First add a button to the login page: GET /fxa-oauth/login?redirect=https://web-ui/#login-cb
  2. When the user clicks it will do the oauth-dance and come back to your redirect endpoint.
  3. At this time just GET /fxa-oauth/token to get the user oauth-token.