Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rémy HUBSCHER Natim

🏠
Working from home
View GitHub Profile
@Natim
Natim / vimeo.html
Created Apr 3, 2012
Vimeo Javascript Display Thumb
View vimeo.html
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function vimeoLoadingThumb(id){
var url = "http://vimeo.com/api/v2/video/" + id + ".json?callback=showThumb";
var id_img = "#vimeo-" + id;
var script = document.createElement( 'script' );
script.type = 'text/javascript';
@Natim
Natim / Document.xlsm
Created Apr 7, 2012
Web Browser Back Button in VBA for Office Excel - history.go(-1) in Excel
View Document.xlsm
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 / gist:2420717
Created Apr 19, 2012
Django UploadFile
View gist:2420717
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 / backends.py
Created Apr 19, 2012
ObjectPermission in Django
View backends.py
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 / directory tree
Created Jun 7, 2012
Getting started with CouchdbKit
View directory tree
greetings/
├── _design
│   └── greetings
│   └── views
│   └── all
│   └── map.js
└── greetings.py
4 directories, 2 files
@Natim
Natim / models.py
Created Jun 28, 2012
Django French Phone Template Tag
View models.py
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 / email_cleaner.py
Created Aug 10, 2012
Extract email from a file, make them unique and sort them.
View email_cleaner.py
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 / language_app.py
Created Aug 18, 2012
Flask language_dispatch : Detect the user language and redirect to the right domain_name
View language_app.py
# -*- coding: utf-8 -*-
import locale
import re
from flask import Flask, redirect, request
app = Flask(__name__)
LANGUAGE_CODES = ('fr', 'en', 'zh')
DOMAIN_NAME = 'example.com'
@Natim
Natim / .emacs
Last active Oct 9, 2015
Emacs configuration
View .emacs
;; 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 / reader.py
Created Aug 29, 2012
Read and URL and get the file from cache if possible or update the file.
View reader.py
# -*- coding: utf-8 -*-
import hashlib
import datetime
import settings
import requests
import os
from wsgiref.handlers import format_date_time
INPUT_CACHE_DIR = getattr(settings, 'INPUT_CACHE_DIR', '/tmp')
You can’t perform that action at this time.