Skip to content

Instantly share code, notes, and snippets.

View benfavre's full-sized avatar
💻
At the office

Webdesign29 benfavre

💻
At the office
View GitHub Profile
@benfavre
benfavre / bulk_delete_adresses.js
Created February 7, 2013 12:36
Mailjet: Supprimer des adresses d'expédition en masse
// Use this script in the dev tools console in Google Chrome
// You might have to run it multiple times and refresh the page each time
table = $($0); // Select table with mail list in inspector
count = 0;
$('tr', table).each(function() {
row = $(this);
link = $('ul.dropdown-menu li:last-of-type a', row);
link_status = row.find(':nth-child(6)');
@benfavre
benfavre / load_async.js
Last active December 16, 2015 05:39 — forked from ngryman/snippet.js
Load Javascript files asynchonously
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
@benfavre
benfavre / functions.php
Created April 22, 2013 18:36
Cleanup Shortcode #WordPress #functions.php
<?php
// A mettre dans functions.php
add_filter('the_content', 'clean_p_shortcode');
function clean_p_shortcode($content){
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
/*
Allows for ajax requests to be run synchronously in a queue
Usage::
var queue = new $.AjaxQueue();
queue.add({
url: 'url',
@benfavre
benfavre / import
Created January 10, 2014 20:37
Mysql Import csv files
LOAD DATA INFILE 'file.csv' INTO TABLE commandes
FIELDS TERMINATED BY ';' ENCLOSED BY ''
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(column1, column2);
@benfavre
benfavre / -README.md
Created February 19, 2016 17:44 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@benfavre
benfavre / dos2unix_recursive
Created July 8, 2016 10:36
Recursively replace line ending in linux
find . -type f -print0 | xargs -0 dos2unix
// see : http://superuser.com/questions/757081/how-do-i-convert-all-files-in-a-folder-to-a-different-line-ending-on-windows
@benfavre
benfavre / .js
Created September 5, 2016 15:59
Serialize Form to JSON
(function ($) {
$.fn.serializeFormJSON = function (options) {
options = jQuery.extend({}, options);
var self = this,
json = {},
push_counters = {},
patterns = {
"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
@benfavre
benfavre / boot_app.sh
Created September 26, 2016 15:12
Boot file
#!/bin/sh
export DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive
echo "App boot script"
export APP_DATABASE_HOST="db"
echo "Setup env variables"
/sbin/setuser www-app cp /var/www/html/.env.example /var/www/html/.env && \
sed -i "s|%database_name%|${APP_DATABASE_NAME}|g" /var/www/html/.env && \
sed -i "s|%database_user%|${APP_DATABASE_USER}|g" /var/www/html/.env && \
@benfavre
benfavre / .env.example
Created September 26, 2016 15:13
ENV file example
APP_DATABASE_NAME=%database_name%
APP_DATABASE_USER=%database_user%
APP_DATABASE_PASSWORD=%database_password%
APP_DATABASE_HOST=%database_host%
APP_ENV=%app_environment%