Skip to content

Instantly share code, notes, and snippets.

View abulte's full-sized avatar

Alexandre Bulté abulte

View GitHub Profile
@abulte
abulte / python-csv-fail-parsing-csv-doublequote.py
Created October 3, 2018 15:51
python-csv-fail-parsing-csv-doublequote
import re
def _guess_quote_and_delimiter(data, delimiters=None):
"""
Looks for text enclosed between two identical quotes
(the probable quotechar) which are preceded and followed
by the same character (the probable delimiter).
For example:
,'some text',
The quote with the most wins, same with the delimiter.
## The order of the types in this file is important.
## This file exposes an array that defines the order in which the types will be matched.
##
## Always ensure that the extensions (and related) are properly lowercased.
version: '1'
types:
- name: gpkg
extensions:
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
@abulte
abulte / backup_glacier.py
Created November 15, 2012 17:09
Simple AWS Glacier backup for files and MySQL DB
#!/usr/bin/env python
import sys
from datetime import datetime
import subprocess
DB_LOGIN = 'root'
DB_PASSWD = 'XXXX'
VAULT_NAME = 'backup_sunny'
HOSTNAME = 'Sunny'
@abulte
abulte / COPYING.txt
Created October 23, 2012 21:17
Build a custom Raspian image #2
# originally copied from http://michael.gorven.za.net/blog/2012/10/22/building-raspbian-images-raspberry-pi
# Copyright (C) 2012 Michael Gorven <http://michael.gorven.za.net/>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@abulte
abulte / gist:8112151
Last active May 14, 2016 16:30
Angular CORS *BAD* pratice
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}
]);
@abulte
abulte / htaccess
Created December 24, 2013 11:44
WordPress AngularJS CORS setup
# CORS Headers (add this)
<ifModule mod_headers.c>
Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "X-Requested-With, content-type"
</ifModule>
# BEGIN WordPress (you should have this in your original WP .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
@abulte
abulte / directive.js
Last active January 2, 2016 20:29
Test fast click efficiency on mobile
module.directive('mesureTime', function() {
return {
restrict: 'A',
// require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
var timeTouch;
elm.on('click', function() {
if (timeTouch) {
alert(new Date().getTime() - timeTouch, " ms");
} else {
@abulte
abulte / entity_menu_links-depends-on-i18n_menu.patch
Last active December 27, 2015 07:28
Patch entity_menu_links to depend on i18n_menu #drupal
@abulte
abulte / drupal-7-fetch-siblings-menu.php
Created October 24, 2013 12:05
Drupal 7 Fetch siblings of node in menu
<?php
// requires Menu Node API https://drupal.org/project/menu_node
// [ALB] ripped from submenutree.module
// Traverse down the tree to find our node, following in_active_trial
// This code stanza is loosely inspired by menu_set_active_trail()
$item = $current_item;
$tree = menu_tree_all_data($item['menu_name'], $item);
$my_tree = FALSE;