Skip to content

Instantly share code, notes, and snippets.

View guillaumepiot's full-sized avatar

Guillaume Piot guillaumepiot

View GitHub Profile
@guillaumepiot
guillaumepiot / gist:b8f68db3e889938c6816
Last active August 29, 2015 14:02
POLYFILL - Background size cover for IE
// Add the following in a CSS class using background-size:cover;
// IE polyfill for background size
// -ms-behavior: url('/static/css/backgroundsize.min.htc');
<!-- background-size-polyfill v0.2.0 | (c) 2012-2013 Louis-Rémi Babé | MIT License -->
<PUBLIC:COMPONENT lightWeight="true">
<PUBLIC:ATTACH EVENT="oncontentready" ONEVENT="o.init()" />
<PUBLIC:ATTACH EVENT="ondocumentready" ONEVENT="o.init()" />
<PUBLIC:ATTACH EVENT="onpropertychange" ONEVENT="o.handlePropertychange()" />
<PUBLIC:ATTACH EVENT="ondetach" ONEVENT="o.restore()" />
@guillaumepiot
guillaumepiot / gist:fed87de0433bd4ac4d46
Created May 27, 2014 15:14
OS Mavericks - general pip install error
Mavericks install error:
clang: error: unknown argument: '-mno-fused-madd'
We must tell the OS to ignore the error.
Just type the following:
$ export CFLAGS=-Qunused-arguments
$ export CPPFLAGS=-Qunused-arguments
@guillaumepiot
guillaumepiot / gist:71624556ef785c262899
Created May 15, 2014 14:55
REGEX - Catch most html tags
Regex to catch some html tags (does not catch it all though, but does clean up most of it)
<[a-z0-9\:\;\"\{\}\=\/\s\#\-\.\%\_]+>
@guillaumepiot
guillaumepiot / gist:2884ad0361ffb142fcc5
Last active August 29, 2015 14:00
Protractor selection helper
// Select an object attribute
obj.getAttribute('class').then(function(attr){
console.log(attr);
})
// Get an element inner html
obj.getInnerHtml().then(function(html){
console.log(html);
})
@guillaumepiot
guillaumepiot / gist:9760507
Created March 25, 2014 12:07
PHP - Dump MySQL
<?php
$DBUSER="user";
$DBPASSWD="password";
$DATABASE="user_db";
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
$mime = "application/x-gzip";
header( "Content-Type: " . $mime );
@guillaumepiot
guillaumepiot / gist:8860701
Created February 7, 2014 10:58
Django Weekend - Good practices

#Good practices for project management in Django

#Setting up the environment

Each Django project should be encapsulated in its own virtual environment, allowing us to manage the requirements and dependencies independently.

If you don't have Virtualenv installed, please visit this page and download the virtualenv package. For a simple installation:

@guillaumepiot
guillaumepiot / gist:8473955
Last active December 16, 2022 15:31
PYTHON / DJANGO - CSV Export view
def export_profile(request):
import csv, StringIO, datetime
date = datetime.datetime.now()
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="profiles-%s.csv"' % (date.strftime('%d-%m-%Y'))
writer = csv.writer(response)
@guillaumepiot
guillaumepiot / gist:7942710
Last active December 31, 2015 05:39
GOOGLE MAP - Load map from Lat/Lng coordinates
// This script will load a Google map in #map_canvas (div)
//
// You must include the Google map library in the head of your document:
// <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
//
// The #map_canvas must have a minimim height to show.
// eg: #map_canvas { height:300px; }
//
// Then, at the bottom of the page, or after <div id="map_canvas"></div>
// Include the following JS:
@guillaumepiot
guillaumepiot / gist:7805726
Created December 5, 2013 14:12
UNSLIDER JS - Thumbnails navigation control and trailer
// Extension for unslider.js, add a thumbnail trailer
// HOW TO USE
// Include this script in your page first, after unslider.js
// Then output the thumbnails as follows:
// <div class="slide-control">
// <a href="#prev" class="unslider-arrow prev"></a>
// <a href="#next" class="unslider-arrow next"></a>
// <div class="thumbnail_slider" style="width: 368px;">
@guillaumepiot
guillaumepiot / gist:7693860
Created November 28, 2013 15:40
PYTHON - Clean GET var ready for DB query
import re
identifier = re.sub('\W+', ' ', identifier).strip()