Skip to content

Instantly share code, notes, and snippets.

View npotier's full-sized avatar
😀

Nicolas Potier npotier

😀
View GitHub Profile
@npotier
npotier / check_url.sh
Last active October 24, 2017 15:20
Check URL response code and notify it to slack
#!/bin/bash
# The URL you want to check
url="HTTP_MY_AWESOME_URL"
status_code=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' $url)
date=`date`
# The channel or user you want to notify
channel="MY_CHANNEL"
# The displayed bot username
@npotier
npotier / convert.php
Created December 4, 2017 23:22
Replace IMG src link tag with IMG embed content encoded in base64
<?php
/**
* @author Nicolas Potier <nicolas.potier@acseo.fr>
*
* Convert img src="" present in HTML page to <img src="data:image..."
* This Script is inspired by https://joekuan.wordpress.com/2015/02/01/converting-html-document-with-img-src-link-to-img-embedded-data-in-php/
*
* usage : php convert.php source.html destination.html
*
*/
@npotier
npotier / gist:b6a04b9ed74eecceafd61da4ac972fb2
Created April 2, 2018 20:30 — forked from Nyholm/gist:317df136ded2087649d0c9c464285cb1
Show who contributed to your vendors folder
# Install git fame
gem install git_fame
# Install all vendors with source
rm -rf vendor/*
composer update --prefer-source
# Do the calculations. This might take 30 minutes to complete.
rm output.txt
find ./vendor -type d -depth 2 ! -path "./vendor/composer" -exec echo {} \; -exec git fame --sort=loc --hide-progressbar --repository={} \; >> output.txt
@npotier
npotier / convertXMLToArray.php
Last active March 21, 2019 12:15
PHP Convert XML to array
<?php
// This code show how you can easily convert a XML file to an associative array
// var_dump(
// json_decode(
// json_encode(
// simplexml_load_string(
// file_get_contents(
// "https://gist.githubusercontent.com/npotier/5732b6311d2baf95c0e6d5dd7fdeb93f/raw/f6c751f85ad6e646c6f89c81a5ee3a8d452151f5/sample.atom"
// )
@npotier
npotier / gist:816b6f3b521d8701e1fc3ca63f66092f
Created December 28, 2020 21:20
Simple & Free OCR for PDF document in MacOS
brew install ocrmypdf
ocrmypdf inputfile.pdf ocrized_outputfile.pdf
@npotier
npotier / gist:0c9bfa330e877d45c4f8f5c4859288e5
Created September 10, 2021 07:33
Regex replace assertAttributeEquals by assertEquals in PHPUnit
This is a search replace instruction to replace deprectated assertAttributeEquals by assertEquals in PHPUnit code :
Search : \$this->assertAttributeEquals\(([$\[\]|a-zA-Z1-9 ,]+), '([a-zAZ])([a-zAZ]+)', ([$1-9a-zA-Z\->]+)\);
Replace : $this->assertEquals($1, $4->get\U$2$3());
@npotier
npotier / gist:be13486b34db0f19a834a392ade2d3f8
Created October 13, 2021 12:50
Delete Redmine issues from command line
# https://www.redmine.org/boards/2/topics/62095
# RAILS_ENV=production bin/rails console
> p = Project.find("$project_name")
> p.issues.where("closed_on < '#{365.days.ago}'").each(&:destroy)
# To perform this actions across all projects...
> Issue.where("closed_on < '#{365.days.ago}'").each(&:destroy)