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 / 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 };
}
},
@webflo-dev
webflo-dev / sed cheatsheet
Created August 28, 2020 13:08 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@webflo-dev
webflo-dev / rclone-cron.sh
Created October 4, 2020 12:14 — forked from jaredmales/rclone-cron.sh
An rclone backup script for cron
#!/bin/bash
##############################################################################
# An rclone backup script by Jared Males ([email protected])
#
# Copyright (C) 2018 Jared Males <[email protected]>
#
# This script is licensed under the terms of the MIT license.
# https://opensource.org/licenses/MIT
#
@webflo-dev
webflo-dev / enum.go
Created December 22, 2020 10:59 — forked from lummie/enum.go
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@webflo-dev
webflo-dev / modal.jsx
Created April 14, 2021 09:52 — forked from viclafouch/modal.jsx
An implementation of a Modal Component with React Hooks ! See https://react-modal.viclafouch.vercel.app
import React, { useEffect, useImperativeHandle, useState, forwardRef, useCallback } from 'react'
import { createPortal } from 'react-dom'
import './styles.css'
const modalElement = document.getElementById('modal-root')
export function Modal({ children, fade = false, defaultOpened = false }, ref) {
const [isOpen, setIsOpen] = useState(defaultOpened)
const close = useCallback(() => setIsOpen(false), [])
@webflo-dev
webflo-dev / README.md
Created June 25, 2021 16:24 — forked from deviantony/README.md
Portainer HTTP API by example

Introduction

This document presents a simple way to manage your Docker resource by using Portainer as a gateway (HTTP queries against the Portainer API).

The API documentation is available here: https://app.swaggerhub.com/apis/deviantony/portainer/

WARNING: This documentation is valid for Portainer >= 1.18.0.

NOTE: I'm using httpie to execute HTTP queries from the CLI.

/** Operators */
const map = (mapper) => (reducer) => (acc, val) => reducer(acc, mapper(val));
const filter = (predicate) => (reducer) => (acc, val) =>
predicate(val) ? reducer(acc, val) : acc;
const some = (predicate) => (_) => (acc, val) =>
acc !== true ? predicate(val) : true;
/** */
@webflo-dev
webflo-dev / alttab
Created February 14, 2022 16:01 — forked from SidharthArya/alttab
Sway Windows Manager Alt Tab behavior
#!/usr/bin/env python3
import sys
import json
import subprocess
direction=bool(sys.argv[1] == 't' or sys.argv[1] == 'T')
swaymsg = subprocess.run(['swaymsg', '-t', 'get_tree'], stdout=subprocess.PIPE)
data = json.loads(swaymsg.stdout)
current = data["nodes"][1]["current_workspace"]