Skip to content

Instantly share code, notes, and snippets.

View djfm's full-sized avatar
💭
Freelance. Won't set foot in office again.

François-Marie de Jouvencel djfm

💭
Freelance. Won't set foot in office again.
View GitHub Profile
<?php
$translations = require 'install.php';
echo "<meta charset='utf8'>";
echo implode('', array_map(function ($value) {
return "<p>$value</p>";
}, $translations['translations']));
@djfm
djfm / foreach_submodule.js
Last active March 30, 2018 09:06
Execute git submodule foreach... in parallel! Useful for PrestaShop development :)
#!/usr/bin/nodejs
var fs = require('fs');
var spawn = require('child_process').spawn;
function parseSubmodules(data) {
var lines = data.split(/\n+/);
var modules = {};
var currentPath;
#cloud-config
hostname: prestacoreos
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMPxhavnLUdZd7wafQGBhbNqBAW1xfOBDCmLJ65t8FO3t4q39yAQmcEIM6fyhcgnYUl1iCpU/1Wm2JPwjHwFd0du7XDCuJaBDvoNC/oSv5rGcXdKLa5BXJo59k8s6/xYmpz6l6o0Kf5P+nfdhyrBvCbHUZxpX9iQPuEIRpH/s+k4/K815p+wsV+z7z7RSbAJLTxsrtQRpwu/3PvG+2HQZ9AXqjUwXI07LhwUkPSfRQOTeQEzOpeqnx+YSCtrnRlnEegKUKEyewU5bHfAuRQ1AA8VMdekaCeb5LNzCDQxv+Z+utzaY6pW/huHfkBTsOjwnKWIpnb48PC4D7icw7vS7l
users:
- name: djfm
coreos-ssh-import-github: djfm
groups:
- sudo
@djfm
djfm / gist:62842960753ba183e459
Last active August 29, 2015 14:11
Fibonacci tick
<?php
/**
* This will display the first 10 numbers of the Fibonacci sequence.
* Really.
*/
declare(ticks=1);
$a = 0;
@djfm
djfm / gist:8222dbd1db270a258087
Created February 10, 2015 08:36
Map Crowdin Translations (PrestaShop)
$('td.uploaded-file-name').each(function (i, td) {
var $td = $(td);
var $crowdinFileSelect = $td.closest('tr').find('td.source-file select');
var filename = $td.text();
var m;
function select(title) {
var option = $($crowdinFileSelect.find('[title="' + title + '"]')).val();
$crowdinFileSelect.val(option);
}
@djfm
djfm / gist:af67eb0616b19c9b54e5
Last active August 29, 2015 14:15
Clean PSTAF shops
#!/bin/bash
echo "SHOW DATABASES LIKE '%tmpshpcpy%'" | mysql -h127.0.0.1 -P3307 -uroot | \
sed -n '1!p' | xargs -I{} mysql -h127.0.0.1 -P3307 -uroot -e "DROP DATABASE {}"
sudo rm -Rf /www/*tmpshpcpy*
@djfm
djfm / php getStatusAndLocation
Created February 11, 2015 08:13
getStatusAndLocation
function getStatusAndLocation($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
$headers = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
@djfm
djfm / gist:185db29b4b3b8850d9df
Last active August 19, 2016 00:28
Clone All Repositories From GitHub Organization
curl -s https://api.github.com/orgs/PrestaShop/repos | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["ssh_url"]} --recursive]}'
{
"env": {
"es6": true,
"node": true
},
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"plugins": [
@djfm
djfm / waitForBrowserSide.js
Created March 24, 2016 15:21
Useful webdriver.io command to wait for things in the browser's JS execution environment
browser.addCommand('waitForBrowserSide', function waitForBrowserSide (callback) {
return browser
.timeoutsAsyncScript(10000)
.executeAsync(function thisRunsInsideTheBrowser(callback, done) {
setInterval(function () {
if (callback()) {
done();
}
}, 100);
}, callback)