Skip to content

Instantly share code, notes, and snippets.

View C-Duv's full-sized avatar

Duvergier Claude C-Duv

View GitHub Profile
@C-Duv
C-Duv / mongoose-gh7608-pass_data_from_debug_to_post_hook.js
Created March 14, 2019 17:05
Mongoose - GH7608: Pass data from debug to post hook
const { MongoMemoryServer } = require('mongodb-memory-server');
const mongoose = require('mongoose');
const mongoServer = new MongoMemoryServer({
'instance': {
'dbName': 'temp',
'port': 35555,
}
});
@C-Duv
C-Duv / steamdb-bookmarklet.js
Created June 10, 2019 17:22
Bookmarklet to open Steam Database (steamdb.info) page from Steam Store (store.steampowered.com) page
/**
How to use:
1/ Use the following line as the "URL" of a bookmark in your web browser.
2/ Place the bookmark in the bookmark bar for easy access.
3/ When on a steampowered.com page, click on the bookmark and the corresponding steamdb.info page will open.
*/
javascript:(function(){if (window.location.hostname == 'store.steampowered.com') {var pathMatch = window.location.pathname.match(/^\/(?<appType>(app|bundle|sub))\/(?<appId>\d+)\//);pathMatch && window.open('https://steamdb.info/' + pathMatch.groups.appType + '/' + pathMatch.groups.appId + '/?source=bookmarklet','_blank');}})();
@C-Duv
C-Duv / README.md
Last active December 19, 2019 12:07
Mongoose - Trying to determine collection and operation inside hook for insert/update/delete queries

This gist is to help me find a way to determine the updated collection and the operation (document insertion, update or removal) from inside a Mongoose hook.

How to run

  1. git clone this gist
  2. Run npm install
  3. Execute with node app.js
@C-Duv
C-Duv / commands.sh
Last active February 12, 2020 17:27
Commands to build ipxe files via Docker (using a Debian 10.2 image)
# Path where to work
IPXE_DIRPATH="/opt/ipxe"
# Create some directories
mkdir -p "${IPXE_DIRPATH}/"{ipxe_project,builder}
# Fetch iPXE source files
cd "${IPXE_DIRPATH}/ipxe_project"
git clone https://github.com/ipxe/ipxe.git .
@C-Duv
C-Duv / svn-unexpand_id.sh
Created April 1, 2021 13:32
Unexpand the "svn:id" SVN property ($Id$)
#!/bin/bash
# Unexpand the "svn:id" SVN property ($Id$)
#
# Anywhere the expanded "$Id$" string (eg. "$Id: Foobar.php 42 1970-01-01 00:00:00Z jdoe$")
# is found, it is replaced by "$Id".
# Usefull to quickly compare code file-by-file
DIR="$1"
@C-Duv
C-Duv / Commented-regex.php
Created August 8, 2022 22:51
Écrire une regex de manière lisible via des commentaires
<?php
// Ajoute le namespace CSS à chaque "début de mot" en gérant le
// fait que les noms de classe peuvent contenir des "-".
// Cela doit être géré de manière particulière car \w = [a-zA-Z0-9_]
preg_replace(
// Partie de RegEx | Correspond à...
// -------------------- | -------------
//(?<!-) | Si ce qui suit n'est pas précédé d'un "-"