.
Derniers snippets
Echo Snippet
[BASH] add ip in FAIL2BAN whitlist (ipv4)
#!/bin/sh
# ignoreipstuff.sh
#
# Whitlist IPs in FAIL2BAN (IPV4)
#
# How to use: ./ignoreipstuff.sh 1.1.1.1
# by E32
if [[ $EUID -ne 0 ]]; then
echo " 💥You must be root to run this script. "
exit
fi
# Edit IP you want to put in ignore list.
monipamoi=""
MONFILE="/etc/fail2ban/jail.local"
# Script don't touch
echo -e "\n Script: $0 \n"
[[ -z "$1" ]] && echo " [ADD IP] $monipamoi to $MONFILE" || monipamoi=$1
# && echo " ADD IP: $monipamoi"
# Check si le fichier existe !
if [[ -f $MONFILE ]];then
echo " ✅$MONFILE exists"
else
echo " ⛔$MONFILE doesn't exist"
exit 1
fi
pyestonsed() {
sed -i "/ignoreip /c\ignoreip = 127.0.0.1/24 192.168.1.0 $monipamoi" $MONFILE
}
backupfile() {
#On backup avant de tout nicker
cp /etc/fail2ban/jail.local /etc/fail2ban/jail.local_backup
}
# On execute le bourdel
# Check si la ligne à modifier exist
# -q, --quiet, --silent
if grep -q ignoreip "$MONFILE"
then
echo " ✅ OK let's go Baby"
[[ -z "$monipamoi" ]] && echo " NO IP provided ... exit script !" ; exit 1 || echo " ADD IP: $monipamoi"
backupfile
pyestonsed
else
echo " ⛔ NO code to modify found"
exit 1
fi
#
echo -e "\n ✅remplacement IP: ${monipamoi} [OK]\n"
bash
<iframe width="100%" height="1280" src="https://snippet.echosystem.fr?embed=6036b611b2e28" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 26/02/2021
[SHELL] Debian init.d for python script
#! /bin/sh
# /etc/init.d/DayzStat.sh
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DAEMON=/home/dayz/Dayz/server/Namalsk2/config/DayzStat_20.py
echo -e "☰ stat-dayz ${DAEMON} "
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
case "$1" in
start)
echo -e "Starting stat-dayz ${DAEMON} "
python ${DAEMON} &
;;
stop)
echo "Stopping stat-dayz... "
# kill application you want to stop
kill $(ps aux | grep "${DAEMON}" | awk '{print $2}')
#killall python ( to kill al python script )
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
echo "Usage: {start|stop|status}"
exit 1
;;
esac
exit 0
python bash
<iframe width="100%" height="1028" src="https://snippet.echosystem.fr?embed=603631a305df9" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 24/02/2021
[AJAX] Loading screen waiting on php exec
<html>
<head>
<title>loading please wait</title>
</head>
<body>
<div id="loading_div" style="display:none; width: 500px; margin:auto; margin-top: 50px; text-align: center">Veuiller patientez pendant l'execution du script <br /><br /><img src="ajax-loader.gif" /></div>
<script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: 'newpage.php',
type: "POST",
beforeSend: function(){
$("#loading_div").show();
},
success: function(retour){
$('#loading_div').html(retour);
}
});
});
</script>
</body>
</html>
source: https://forum.alsacreations.com/profile-40255-Apoooo.html
ajax php
<iframe width="100%" height="650" src="https://snippet.echosystem.fr?embed=5fc78800af765" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 02/12/2020
[PHP] get data from div on external page.
<?php
// GET content from div
$getcontents = "https://steamcommunity.com/sharedfiles/filedetails/?id=2116151222";
$data_scrapped = file_get_contents($getcontents);
$the_start = explode('<div class="detailsStatsContainerRight">', $data_scrapped);
$the_end = explode('</div>',$the_start[1]);
echo $the_end[0];
?>
php
<iframe width="100%" height="452" src="https://snippet.echosystem.fr?embed=5fc41cdb22bc6" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 29/11/2020
[PHP] load time execution on page
Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
The following code has to be put at the very end of the web page (or the end of the PHP code part)
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>
source : https://stackoverflow.com/a/25231173/8396238
php
https://stackoverflow.com/a/25231173/8396238
<iframe width="100%" height="596" src="https://snippet.echosystem.fr?embed=5fc41c4f404f2" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 29/11/2020
[Bash] Duration execution script
#!/bin/bash
# Stats run script
function time_executiom_script() {
echo "This script took $SECONDS seconds to execute"
}
# your function / stuff here
time_executiom_script
bash
<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5fa2bdafdd9fd" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 04/11/2020
FIX Footer in bottom page
#footer {
position:absolute;
bottom:0;
width:100%;
height:40px; /* Height of the footer */
}
CSS
<iframe width="100%" height="290" src="https://snippet.echosystem.fr?embed=5fa1747218012" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 03/11/2020
stylus nextcloud fix color add file
/* new file text Yellow */
.oc-dialog .fileexists th label {
font-weight: normal;
color: #f2e923;
}
CSS stylus
<iframe width="100%" height="290" src="https://snippet.echosystem.fr?embed=5f0e082a5f8f4" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 14/07/2020
git echosystem.fr
// Full WIDTH
/*full width*/
.ui.container:not(.fluid) {
width: 90% !important;
}
.full.height {
padding: 0;
margin: 0 0 -80px 0;
min-height: 100%;
}
.ui.container {
width: 1327px;
margin-left: auto !important;
margin-right: auto !important;
}
// Dark theme
:root {
--body-bg: white;
--body-color: black;
--anchor-color: red;
--letter-spacing: 0;
}
@media (prefers-color-scheme: dark) {
html {
filter: invert(1) hue-rotate(.5turn);
}
img {
filter: invert(1) hue-rotate(.5turn);
}
img:not(:hover) {
opacity: .7;
transition: opacity .25s ease-in-out;
}
:root {
--body-bg: #403e3e;
--body-color: white;
--anchor-color: salmon;
--letter-spacing: 0;
}
}
body:not(.full-width) {
background-color: var(--body-bg);
letter-spacing: var(--letter-spacing);
}
.ui.menu .ui.dropdown .menu > .item:hover {
background: rgba(0,0,0,.05) !important;
/* color: rgba(85, 162, 200, .95) !important;*/
color: #1e70bf !important;
}
.following.bar .top.menu a.item:hover {
color: #bf611e !important;
}
.ui.secondary.pointing.menu .active.item:hover {
border-color: #1b1c1d;
color: #bf611e !important;
}
.ui.card > .extra a:not(.ui) , .ui.cards > .card > .extra a:not(.ui) {
color: #1e70bf;
}
.ui.card > .extra a:not(.ui):hover, .ui.cards > .card > .extra a:not(.ui):hover {
color: #989da2;
}
.markdown:not(code) pre {
word-wrap: normal;
background-color: #cbcbcb;
}
git CSS stylus
git.echosystem.fr
<iframe width="100%" height="1586" src="https://snippet.echosystem.fr?embed=5f0e078848690" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 14/07/2020
Dark theme II
<input type="checkbox" id="switch">
<div class="app">
<div class="body">
<div class="main-circle"></div>
<div class="phone">
<!-- Top -->
<div class="menu">
<div class="time">4:20</div>
<div class="icons">
<div class="network"></div>
<div class="battery"></div>
</div>
</div>
<!-- Middle -->
<div class="content">
<div class="circle">
<div class="crescent"></div>
</div>
<p class="heading">Choose a style</p>
<p>Pop or subtle. Day or night.<br>
Customize your interface
</p>
<label for="switch">
<div class="toggle"></div>
<div class="names">
<p class="light">Light</p>
<p class="dark">Dark</p>
</div>
</label>
<div class="mark"></div>
</div>
<!-- Bottom -->
<div class="skip">
<p>Skip</p>
<div class="fab">
<div class="arrow"></div>
</div>
</div>
<div class="swipe"></div>
</div>
</div>
<div class="credit">
<p>Inspired by <a href="https://dribbble.com/shots/6155384-Coded-Light-dark-toggle-switch" target="_blank">Matthieu Souteyrand</a></p>
</div>
</div>
<style>
/* GENERAL */
@import url('https://fonts.googleapis.com/css?family=Rubik');
.credit {
position: fixed;
right: 2rem;
bottom: 2rem;
color: white;
}
.credit a {
color: inherit;
}
body{
margin: 0;
padding: 0;
font-family: 'Rubik', -apple-system, BlinkMacSystemFont,
"Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans",
"Droid Sans", "Helvetica Neue", sans-serif;;
}
.body {
position: relative;
width: 100vw;
height: 100vh;
background-color: #fff;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
transition: background-color .1s;
}
/* Main Circle */
.main-circle {
width: 40rem;
height: 40rem;
border-radius: 100%;
background: linear-gradient(40deg, #FF0080,#FF8C00 70%);
position: absolute;
z-index: 1;
left: 50%;
transform: translate(-50%, -70%)
}
/* Phone */
.phone {
position: relative;
z-index: 2;
width: 21rem;
height: 45rem;
background-color: inherit;
box-shadow: 0 4px 35px rgba(0,0,0,.1);
border-radius: 40px;
display: flex;
flex-direction: column;
}
.swipe {
width: 40%;
height:.25rem;
background-color: black;
opacity: .15;
border-radius: 10px;
margin: .5rem auto;
}
/* Top */
.menu {
/* background-color: blue; */
font-size: 80%;
opacity: .4;
padding: .8rem 1.8rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.icons {
display: flex;
margin-top: .5rem;
}
.battery {
width: .85rem;
height: .45rem;
background-color: black;
}
.network {
width: 0;
height: 0;
border-style: solid;
border-width: 0 6.8px 7.2px 6.8px;
border-color: transparent transparent black transparent;
transform: rotate(135deg);
margin: .12rem .5rem;
}
/* Middle */
.content {
display: flex;
flex-direction: column;
margin: auto;
text-align: center;
width: 70%;
transform: translateY(5%);
}
.circle {
position: relative;
border-radius: 100%;
width: 8rem;
height: 8rem;
background: linear-gradient(40deg, #FF0080,#FF8C00 70%);
margin: auto;
}
.crescent {
position: absolute;
border-radius: 100%;
right: 0;
width: 6rem;
height: 6rem;
background: white;
transform: scale(0);
transform-origin: top right;
transition: transform .6s cubic-bezier(0.645, 0.045, 0.355, 1);
}
p {
font-size: 90%;
}
.heading {
font-size: 140%;
font-weight: bolder;
margin: 3rem 0 .2rem 0;
}
label, .toggle {
height: 2.8rem;
border-radius: 100px;
}
label {
width: 100%;
background-color: rgba(0,0,0,.1);
border-radius: 100px;
position: relative;
margin: 1.8rem 0 4rem 0;
cursor: pointer;
}
.toggle {
position: absolute;
width: 50%;
background-color: #fff;
box-shadow: 0 2px 15px rgba(0,0,0,.15);
transition: transform .3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.names {
font-size: 90%;
font-weight: bolder;
width: 65%;
margin-left: 17.5%;
margin-top: .5%;
position: absolute;
display: flex;
justify-content: space-between;
user-select: none;
}
.dark {
opacity: .5;
}
.mark {
border-radius: 100px;
background-color: black;
}
.mark {
width: 7%;
margin: auto;
position: relative;
height: .25rem;
}
.mark::before {
content: '';
position: absolute;
width: .25rem;
height: 100%;
left: -70%;
opacity: .15;
background-color: inherit;
}
.mark::after {
content: '';
position: absolute;
width: .25rem;
height: 100%;
right: -70%;
opacity: .15;
background-color: inherit;
}
/* Bottom */
.skip {
padding: 1.5rem 1.8rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.skip p {
opacity: .55;
font-size: 90%;
cursor: pointer;
transition: all 2s ease;
}
.skip p:hover {
text-decoration: underline;
}
.fab {
box-shadow: 0 2px 10px rgba(0,0,0,.2);
border-radius: 100%;
width: 3rem;
height: 3rem;
display: flex;
justify-content: center;
align-items: center;
position: relative;
cursor: pointer;
transition: transform .5s cubic-bezier(0.19, 1, 0.22, 1);
}
.fab:hover {
transform: scale(1.2);
}
.arrow {
width: 40%;
height: .1rem;
background-color: black;
}
.arrow::before {
content: '';
position: absolute;
height: .1rem;
width: 20%;
background-color: inherit;
transform: rotate(45deg);
right: 26%;
top: 42%;
}
.arrow::after {
content: '';
position: absolute;
height: .1rem;
width: 20%;
background-color: inherit;
transform: rotate(-45deg);
right: 26%;
bottom: 42%;
}
/* -------- Switch Styles ------------*/
[type="checkbox"] {
display: none;
}
/* Toggle */
[type="checkbox"]:checked + .app .toggle{
transform: translateX(100%);
background-color: #34323D;
}
[type="checkbox"]:checked + .app .dark{
opacity: 1;
}
[type="checkbox"]:checked + .app .light{
opacity: .5;
}
/* App */
[type="checkbox"]:checked + .app .body{
background-color: #26242E;
color: white;
}
/* Circle */
[type="checkbox"]:checked + .app .crescent{
transform: scale(1);
background: #26242E;
}
[type="checkbox"]:checked + .app .circle{
background: linear-gradient(40deg, #8983F7, #A3DAFB 70%);
}
[type="checkbox"]:checked + .app .main-circle{
background: linear-gradient(40deg, #8983F7, #A3DAFB 70%);
}
/* Fab */
[type="checkbox"]:checked + .app .fab{
background-color: #34323D;
}
[type="checkbox"]:checked + .app .arrow,
[type="checkbox"]:checked + .app .mark,
[type="checkbox"]:checked + .app .battery{
background-color: white;
}
[type="checkbox"]:checked + .app .network{
border-color: transparent transparent white transparent;
}
[type="checkbox"]:checked + .app .swipe{
background-color: #34323D;
opacity: 1;
}
</style>
darktheme CSS html
https://dribbble.com/shots/6155384-Coded-Light-dark-toggle-switch
<iframe width="100%" height="6392" src="https://snippet.echosystem.fr?embed=5f03038456ebe" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 06/07/2020
Copy boutton HTML/JS
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 140px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 150%;
left: 50%;
margin-left: -75px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
</head>
<body>
<p> Copy text</p>
<input type="text" value="Hello World" id="myInput">
<div class="tooltip">
<button onclick="myFunction()" onmouseout="outFunc()">
<span class="tooltiptext" id="myTooltip">Copy to clipboard</span>
Copy text
</button>
</div>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
var tooltip = document.getElementById("myTooltip");
tooltip.innerHTML = "Copied: " + copyText.value;
}
function outFunc() {
var tooltip = document.getElementById("myTooltip");
tooltip.innerHTML = "Copy to clipboard";
}
</script>
</body>
</html>
html js
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_copy_clipboard2
<iframe width="100%" height="1568" src="https://snippet.echosystem.fr?embed=5efb6768b98c5" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 30/06/2020
netatmo stylus css
.h-fullh {
height: 100%;
background-color: #222222;
color: #308009;
}
body {
background-color: #222222;
font-family: "Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;
font-weight: normal;
font-style: normal;
line-height: 1.5;
cursor: auto;
}
élément {
color: #4fd70b;
background-color: #222222;
}
#persons {
width: 66.66666%;
display: inline-block;
vertical-align: middle;
height: 33.2%;
position: absolute;
top: 66.8%;
left: 0;
padding-top: 20px;
color: #4fd70b;
background-color: #222222;
}
.camera-app #home-view .home-wrapper {
font-size: 16px;
position: relative;
width: 100%;
color: #4fd70b;
background-color: #222222;
}
.home-selector {
z-index: 10;
height: 60px;
box-shadow: 0 0 13px 3px rgba(0, 0, 0, 0.1);
color: #5f0;
background-color: #222222;
}
.flex-center {
display: flex;
justify-content: center;
align-items: center;
color: #4fd70b;
background-color: #222222;
}
.camera-app #home-view .home-wrapper {
font-size: 16px;
position: relative;
width: 100%;
color: #4fd70b;
background-color: #222222;
}
#timeline #timelineList .event .event-selectable.active .event-time span {
color: #44b951;
}
#timeline #timelineList .event .event-selectable .event-message span.liveevent {
color: #d0021b;
text-transform: uppercase;
font-family: ProximaNova-Medium;
font-size: 22px;
}
#timeline #timelineList .event .day-event .day-name {
color: #b1aa42;
}
#timeline {
height: 100%;
position: relative;
width: 50;
padding-left: 15px;
overflow: hidden;
color: #4fd70b;
background-color: #222222;
}
.page-container {
margin-top: 60px;
height: calc(100% - 60px);
overflow: auto;
position: relative;
color: #4fd70b;
background-color: #222222;
}
#persons .person-list {
height: 75%;
background-color: #090808;
border-radius: 0 0 5px 5px;
}
#timeline #timelineList {
width: 100%;
padding: 40px 0 0 0;
position: relative;
background-color: #090808;
}
#timeline #timelineList .event .event-selectable.active {
background-color: #2d2b2b;
}
#timeline #timelineList .event .day-event.fixed {
background-color: #090808;
position: absolute;
top: 0;
left: 0;
border-top: none;
}
#persons .person-mode-selector {
background-color: #000;
border-radius: 5px 5px 0 0;
border-bottom: 1px solid #e7e7e7;
height: 25%;
}
.common-header .header-app {
background: #151515;
border-bottom: 1px solid #87a662;
}
.common-header .right-content {
filter: invert(1);
}
#timeline #timelineList .event .event-selectable .event-image-wrapper .hide-line-first-event-of-day, #timeline #timelineList .event .event-selectable .event-image-wrapper .hide-line-last-event-of-day {
position: absolute;
width: 100%;
height: calc(50% + 15px);
background-color: #090808;
}
/* info camera + option */
.home-info p {
font-family: ProximaNova-SemiBold;
font-size: 15px;
color: #72d03d;
line-height: inherit;
}
.common-subheader .param .icon.settings-admins , .icon.settings ,.icon.camerasettings {
filter: invert(1);
}
#timeline #timelineList .event .event-selectable.active {
background-color: #868080;
}
CSS netatmo stylus
https://my.netatmo.com/app/security
<iframe width="100%" height="2972" src="https://snippet.echosystem.fr?embed=5ea0068999df0" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/07/2020
Date update in html javascript
# Use this to update Year ( footer) with javascript , no php ;)
<script>document.write(new Date().getFullYear())</script>
# That will work in all browsers I've run across.
# You can just call getFullYear directly on the newly-created Date, no need for a variable. new Date().getFullYear() may look a bit odd, but it's reliable: the new Date() part is done first, then the .getFullYear().
# You can drop the type, because JavaScript is the default; this is even documented as part of the HTML5 specification, which is likely in this case to be writing up what browsers already do.
# You can drop the semicolon at the end for one extra saved character, because JavaScript has "automatic semicolon insertion," a feature I normally despise and rail against, but in this specific use case it should be safe enough.
#It's important to note that this only works on browsers where JavaScript is enabled. Ideally, this would be better handled as an offline batch job (sed script on *nix, etc.) once a year, but if you want the JavaScript solution, I think that's as short as it gets. (Now I've gone and tempted fate.)
source : https://stackoverflow.com/posts/4562604/revisions
html js
<iframe width="100%" height="470" src="https://snippet.echosystem.fr?embed=5db70f0c699a2" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 28/10/2019
PHP show_source() Function
# PHP show_source() Function
<html>
<body>
<?php
show_source("show_source.php");
?>
</body>
</html>
php
<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5db084f26f5a0" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 23/10/2019
[CSS] Centrer image with text vertical
<div>
<img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg" style="vertical-align: middle;" width="100px"/>
<span style="vertical-align: middle;">Here is some text.</span>
</div>
CSS html
<iframe width="100%" height="254" src="https://snippet.echosystem.fr?embed=5daf451ece633" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 22/10/2019
awk.awk
("2019-04-13 18:58:25", "EV A2 108 07", "76561198932398051", "y9Wjfk+kp7bGbfi8I8OM5YJK7mwrcUDcHM0rzv0eEF8=", "everyone")
cat $pathDB/Players.json | jq --arg dt "$Dateu" '. | "\($dt),\(.Names),\(.Steam64ID),\(.GUID),\(.Roles[0])"' > $pathDB/Player-ALL-Name.json
awk -F " " '{print $3,$4,$5,$6,",1,"$1,"\x27\x27,\x27\x27,\x27\x27),"}' /home/dayz/DataBase/Player-Last-Name.json
bash
<iframe width="100%" height="272" src="https://snippet.echosystem.fr?embed=5cb22647578d4" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 13/04/2019
updater-netdata.sh
#!/bin/bash
#
# Script Updater for netdata
#
# - Dependencies: Wring package (NPM)
#
# By Erreur32 - 2018
#
service=netdata
releasehub=https://github.com/netdata/netdata/releases
VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
NOC=$(tput sgr0)
NC=$(tput sgr0)
## Check if wring is installed
if [ -f "/usr/bin/wring" ] || [ -f "/usr/local/bin/wring" ]
then
echo -e "\n\e[34m - Wring package \e[0m>> founded.\e[0m\n"
else
echo -e "\n\e[92m - Install Wring with NPM \e[0m\n"
npm install --global wring && echo "Success install Wring" || echo "failure to install Wring"
echo -e "\n\e[34m - .\e[0m\n"
fi
# need to check in other way... /usr/sbin/netdata -V | cut -c"9-" | cut -c "1-6"
VersionInstalled="$(/usr/sbin/netdata -v | cut -c"9-" | cut -c "1-6")"
VersionAvailable="$(curl -s $releasehub | wring text - '.css-truncate-target' | sed -n 5p)"
echo -e "$ROSE Checking $service version ... "
echo -e "$JAUNE Version installed = v$VersionInstalled"
echo -e "$JAUNE Version Available = $VersionAvailable"
echo ""
if [ -z "$VersionInstalled" ]
then
echo -e "$service is not installed - exit "
exit
fi
if [[ "$VersionAvailable" = "v$VersionInstalled" ]]
then
echo -e "$service is already up-to-date (version $VersionInstalled) ... Bye! "
exit
fi
echo -e "$VERT Start install New Updater from Netdata $NC"
if [ -f "/opt/netdata-last-installer.sh" ]
then
rm /opt/netdata-last-installer.sh -f
wget https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose && echo -e "$CYAN Get success last installer " || echo "failure"
chmod +x /opt/netdata-last-installer.sh
else
wget https://my-netdata.io/kickstart.sh -O /opt/netdata-last-installer.sh --no-verbose && echo -e "$CYAN Get success last installer " || echo "failure"
chmod +x /opt/netdata-last-installer.sh
fi
echo -e " $NC"
echo -e "$JAUNE Start Updating Netdata..."
/bin/bash /opt/netdata-last-installer.sh && echo -e " Updating Netdata Successfully!" || echo "failure"
echo ""
echo -e " $VERT Update ✔ Netdata..."
echo -e " $NC"
bash
https://gist.github.com/Erreur32/64108b6fa940bb93654a205503b36f76
<iframe width="100%" height="1550" src="https://snippet.echosystem.fr?embed=5be81b20c9972" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 11/11/2018
Aide Crontab
┌────────── minute (0 - 59)
│ ┌──────── hour (0 - 23)
│ │ ┌────── day of month (1 - 31)
│ │ │ ┌──── month (1 - 12)
│ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or 1 - 7 => Monday - Sunday)
│ │ │ │ │
↓ ↓ ↓ ↓ ↓
* * * * * command to be executed
58 23 * * * /sbin/iptables-save > /etc/firewall.iptables-cron 2>&1
#####
Hope it will help ;)
cron
<iframe width="100%" height="524" src="https://snippet.echosystem.fr?embed=5bdf4d0790a8e" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 04/11/2018
update-plex.sh
#!/bin/bash
#####
#
# This Script will update Plex Media Server to the latest version for Ubuntu
#
# To automatically check & update plex, run "crontab -e" and add the following lines
#
# # Check for Plex Media Server Updates every day @6:00 am
# 0 6 * * * /root/update-plexmediaserver.sh
#
# 2018 - Original by Matthieu Guerry
# - Customised by erreur32
###
# Check Current installed version and exit if latest is already installed
service=plex
VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
if [[ -z $VersionInstalled ]]; then echo " Plex is not installed - exit "; exit; fi
VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
echo -e " Checking Plex version ... "
echo -e " Version installed = $VersionInstalled"
echo -e " Version Available = $VersionAvailable"
if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled) ... Bye! "; exit; fi
echo -e " Download new Version $VersionAvailable"
# Download latest installation package to /tmp folder
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/
if [[ -z $(ps -ef |grep ${service}) ]]
then
print "Hum service down !?! , anyway Service will updating\n"
else
print "Plex is running, service will stop before Update...\n"
fi
# Stop Plex Service
sudo service plexmediaserver stop
# Install latest version
sudo dpkg -i /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")')
ps -ef | grep plex | grep -v grep
[ $? -eq "0" ] && echo "Plex is running back :)" || echo "Plex is not running ... ;("
# Start Plex Service
echo -e " restart service Plex"
sudo service plexmediaserver start
# Remove installation package from /tmp folder
rm /tmp/plexmediaserver_*
bash
<iframe width="100%" height="1118" src="https://snippet.echosystem.fr?embed=5bdf3936ae288" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 11/11/2018
Responsive html with meta
<meta name="viewport" content="width=device-width, initial-scale=1.0">
html
<iframe width="100%" height="236" src="https://snippet.echosystem.fr?embed=5bc9d5fc7798c" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 19/10/2018
Display the Windows upgrade history using PowerShell
With PowerShell open, run the following commands using copy and paste.
Command 1:
$AllBuilds = $(gci "HKLM:\System\Setup" | ? {$_.Name -match "\\Source\s"}) | % { $_ | Select @{n="UpdateTime";e={if ($_.Name -match "Updated\son\s(\d{1,2}\/\d{1,2}\/\d{4}\s\d{2}:\d{2}:\d{2})\)$") {[dateTime]::Parse($Matches[1],([Globalization.CultureInfo]::CreateSpecificCulture('en-US')))}}}, @{n="ReleaseID";e={$_.GetValue("ReleaseID")}},@{n="Branch";e={$_.GetValue("BuildBranch")}},@{n="Build";e={$_.GetValue("CurrentBuild")}},@{n="ProductName";e={$_.GetValue("ProductName")}},@{n="InstallTime";e={[datetime]::FromFileTime($_.GetValue("InstallTime"))}} };
Command 2:
$AllBuilds | Sort UpdateTime | ft UpdateTime, ReleaseID, Branch, Build, ProductName
PowerShell returns previous Windows versions in a table when you execute the second command. If you run Windows 10, you may get various Windows 10 feature updates builds returned to you.
powershell
<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5ab4d0f460af1" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 23/03/2018
extract MP3 from mp4 with ffmpeg
# video.mp4 = input file
# -b flag is for bitrate e.g. 192K, 320K etc.
# -vn = video codec none
ffmpeg -i video.mp4 -b:a 320K -vn music.mp3
bash
<iframe width="100%" height="254" src="https://snippet.echosystem.fr?embed=5a99720e38628" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 02/03/2018
[php] - Compare date
$exp_date = "2006-01-16";
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);
if ($expiration_date > $today) {
$valid = "yes";
} else {
$valid = "no";
}
php
<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5a955d4c85249" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 29/11/2020
Location IP
function detect_city($ip) {
$default = 'UNKNOWN';
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
$ip = '8.8.8.8';
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';
$url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
$ch = curl_init();
$curl_opt = array(
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => $curlopt_useragent,
CURLOPT_URL => $url,
CURLOPT_TIMEOUT => 1,
CURLOPT_REFERER => 'http://' . $_SERVER['HTTP_HOST'],
);
curl_setopt_array($ch, $curl_opt);
$content = curl_exec($ch);
if (!is_null($curl_info)) {
$curl_info = curl_getinfo($ch);
}
curl_close($ch);
if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) ) {
$city = $regs[1];
}
if ( preg_match('{<li>State/Province : ([^<]*)</li>}i', $content, $regs) ) {
$state = $regs[1];
}
if( $city!='' && $state!='' ){
$location = $city . ', ' . $state;
return $location;
}else{
return $default;
}
}
php
https://codepad.co/snippet/9fb3cd
<iframe width="100%" height="1028" src="https://snippet.echosystem.fr?embed=5a955ce19b4a0" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Get the filename of the newest file in a directory
<?php
/**
* Get the filename of the newest file in a directory.
* Optionally specify a filename extension on which to limit the search.
* @param string $directory The name of the directory to search
* @param string $extension If not empty, only files with this extension will be searched
* @return string
* @author Sunny Walker <www.miraclesalad.com>
*/
function getNewestFile($dir, $extension='') {
$handle = opendir($dir);
$return = '';
$the_time = 0;
while ($file = readdir($handle)) {
$fname = $dir.'/'.$file;
if ($file != '..' && $file != '.' && !is_dir($fname)) {
$ext = strtolower(substr(strrchr($file,'.'),1));
$ftime = filemtime($fname);
if (($extension=='' || ($extension!='' && $ext==$extension)) && $ftime>$the_time) {
$the_time = $ftime;
$return = $fname;
}
}
}
return $return;
} //getNewestFile()
?>
php
https://codepad.co/snippet/7bdf40
<iframe width="100%" height="668" src="https://snippet.echosystem.fr?embed=5a955cc8689b0" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Get File Extension
<?php
/**
* Get the (lowercased) extension from a filename.
* @param string $filename The name of the file
* @return string
* @author Sunny Walker <www.miraclesalad.com>
*/
function getFileExt($filename) {
return strtolower(substr(strrchr($filename, '.'), 1));
} //getFileExt()
?>
php
https://codepad.co/snippet/e83837
<iframe width="100%" height="380" src="https://snippet.echosystem.fr?embed=5a955bd46b70c" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Validation mail ( regex)
function isValidEmail($email){
return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $email);
}
$result = isValidEmail('test@test.com=')
php
<iframe width="100%" height="272" src="https://snippet.echosystem.fr?embed=5a955b59835fa" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Display current directory
Both of function display for current directory.
<?php
echo __DIR__."<br/>";
?>
or
<?php
$path = getcwd();
echo $path;
?>
php
https://codepad.co/snippet/bd2c9f
<iframe width="100%" height="398" src="https://snippet.echosystem.fr?embed=5a955a5a2264c" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Get the current page url in php
/* get the current page url in php */
<?php
echo $_SERVER['SCRIPT_NAME']; /* Global variable in php */
?>
php
https://codepad.co/snippet/899f0f
<iframe width="100%" height="254" src="https://snippet.echosystem.fr?embed=5a955a3f0fed0" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018
Delete or create any extension type file(html, php, jpg, gif, flv, swf, etc...)
// Delete any extension type file(html, php, jpg, gif, flv, swf, etc...)
<?php
$file_x = "my_file.txt";
if (file_exists($file_x)) {
unlink($file_x); // delete it here only if it exists
echo "The file has been deleted";
} else {
echo "The file was not found and could not be deleted";
}
?>
// create any extension type file(html, php, xml, etc...)
<?php
$file_x = "my_file.txt";
$createFile = touch($file_x);
if (file_exists($file_x)) {
echo "The file has been created";
} else {
echo "The file has not been created";
}
?>
php
https://codepad.co/snippet/6a61c8
<iframe width="100%" height="704" src="https://snippet.echosystem.fr?embed=5a955a16761dc" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 27/02/2018