Skip to content

Instantly share code, notes, and snippets.

View elfefe's full-sized avatar
💭
Mmmmh... Ah !

elfefe elfefe

💭
Mmmmh... Ah !
View GitHub Profile
@elfefe
elfefe / Overlay.kt
Created September 20, 2024 18:54
Utilitaires Android
\***
* Can be used from any context (Activity, Service, ...)
*\
private fun createOverlay() {
windowManager = getSystemService(WINDOW_SERVICE) as WindowManager
dimView = View(this).apply {
setBackgroundColor(Color.argb(brightnessAlpha, 0, 0, 0))
setTheme(android.R.style.Theme_Holo_NoActionBar_Fullscreen)
@elfefe
elfefe / Config.kt
Last active September 16, 2024 13:47
Utilitaires Kotlin/Compose
package fr.exem.citymapper2.controllers
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
@elfefe
elfefe / Comment exécuter une commande sur des fichier.md
Created November 23, 2023 09:31
Comment exécuter une commande sur des fichier

La commande

sudo find /your/path -maxdepth X -type x -newermt XXXXXXXX \! -newermt XXXXXXXX -exec yourcommand {} \;

Légende

  • find: Commande de recherche de fichier

  • /your/path: Le dossier de départ de la commande

@elfefe
elfefe / Nginx-generate_certificates.md
Created June 15, 2023 18:14
Nginx - Reverse proxy

Generate your certificates using certbot with the following command:

sudo certbot --nginx -d your-server-name.com -d www.your-server-name.com 
@elfefe
elfefe / DetectWall.cs
Last active April 29, 2023 17:32
Wall detection in unity
// The distance where collision will be detected
public float collisionDistance = 3f; ///valeur debut Default
// Return available directions depending on player direction
private Vector3 AvailableDirection()
{
var direction = Vector3.zero;
if (ToucheMur(DirectionalRay(transform.forward)))
@elfefe
elfefe / user_management.sql
Last active April 17, 2023 17:12
PostgreSQL User management
-- REVOKE WRIGHTS TO USER
REVOKE CONNECT ON DATABASE "db" FROM user;
-- Revoke all privileges on tables
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP
EXECUTE 'REVOKE ALL PRIVILEGES ON TABLE ' || quote_ident(r.tablename) || ' FROM user';
@elfefe
elfefe / regex.md
Created April 14, 2023 12:20
Markdown regex

A regex by itself won't be sufficient to fully parse text into Markdown, as Markdown has a variety of syntax rules that can't be captured by a single regular expression. However, I can provide you with a set of regex patterns to help identify some common Markdown elements. You can use these patterns to build a parser or converter:

  1. Headers: ^(#{1,6})\s+(.+)$

  2. Bold text: \*\*(.+?)\*\*|__(.+?)__

  3. Italic text: \*(.+?)\*|_(.+?)_

  4. Strikethrough: ~~(.+?)~~

@elfefe
elfefe / How SSH Work.md
Last active September 20, 2024 18:52
Tunnel & SSH

Popular and technical in depth explanation of the SSH protocol.

Popularize

The Secure Shell (SSH) protocol is a cryptographic network protocol that enables secure communication between two devices over an insecure network. It is widely used for remote access, secure file transfers, and managing network infrastructure. Let's break down how SSH works in a simple, easy-to-understand manner.

  1. Establishing a Connection: When an SSH client (e.g., your computer) wants to connect to an SSH server (e.g., a remote computer), it starts by initiating a "handshake" process. This involves the exchange of information, such as supported protocol versions, encryption algorithms, and other data required to establish a secure connection.

  2. Key Exchange and Encryption Algorithms: Both the client and server need to agree on a common set of encryption and key exchange algorithms to use for secure communication. They exchange their preferences and select the most secure algorithm that both support.

@elfefe
elfefe / GeneticsAIChat.html
Created December 6, 2022 16:38
Little chat with an AI about Genetic
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body><div class="flex-1 overflow-hidden"><div class="react-scroll-to-bottom--css-nghnr-79elbk h-full dark:bg-gray-800"><div class="react-scroll-to-bottom--css-nghnr-1n7m0yu"><div class="flex flex-col items-center text-sm h-full dark:bg-gray-800"><div class="w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group dark:bg-gray-800"><div class="text-base gap-6 m-auto md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0"><div class="w-[30px] flex flex-col relative items-end"><div class="relative flex"><span style="box-sizing: border-box; display: inline-block; overflow: hidden; width: initial; height: initial; background: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; position: relative; max-width: 100%;"><span style="box-sizing: border-box; display: block; width: initial; height: initial; background: none; opacity: 1; border: 0px; margin: 0px; padding: 0px; max-widt
@elfefe
elfefe / ConsoleToFile.md
Created December 2, 2022 09:18
Output console to file in bash

###Overview:

Please note that the n.e. in the syntax column means "not existing".
There is a way, but it's too complicated to fit into the column. You can find a helpful link in the List section about it.

          || visible in terminal ||   visible in file   || existing
  Syntax  ||  StdOut  |  StdErr  ||  StdOut  |  StdErr  ||   file   

==========++==========+==========++==========+==========++===========