Skip to content

Instantly share code, notes, and snippets.

View webflo-dev's full-sized avatar

Florent webflo-dev

View GitHub Profile
@webflo-dev
webflo-dev / read_ini_file.sh
Last active June 29, 2020 18:08
read ini file using shell script
# List all [sections] of a .INI file
sed -n 's/^[ \t]*\[\(.*\)\].*/\1/p' $ini_file
# Read KEY from [SECTION]
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*KEY[ \t]*=[ \t]*//p'
# Read all values from SECTION in a clean KEY=VALUE form
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*\([^#; \t][^ \t=]*\).*=[ \t]*\(.*\)/\1=\2/p'
@webflo-dev
webflo-dev / background.js
Created September 10, 2018 08:45 — forked from davlgd/background.js
Bad Search Engine Blocker - Projet final
chrome.webRequest.onBeforeRequest.addListener(function (request) {
const askedURL = new URL(request.url);
const keywords = askedURL.searchParams.get("q");
if (/bing.|google.|yahoo./.test(askedURL.hostname))
{
const destinationUrl = (keywords) ? "https://www.framabee.org?q=" + keywords : "https://www.framabee.org";
return { redirectUrl: destinationUrl };
}
},