Skip to content

Instantly share code, notes, and snippets.

Avatar
🏢
Working from OSInet

Frédéric G. MARAND fgm

🏢
Working from OSInet
View GitHub Profile
@fgm
fgm / HostsReferencedInPage.js
Created Dec 20, 2019
List the hosts referenced on a HTML page (href, src), by decreasing occurrence count
View HostsReferencedInPage.js
/**
* List the hosts referenced on a HTML page.
*
* Licence: MIT.
*/
a = {};
document.querySelectorAll("a[href],[src]").forEach((v, k) => {
const raw = v.getAttribute("href") || v.getAttribute("src");
if (raw[0] !== "h") {
@fgm
fgm / TenMostRepeatedLinksOnPage.js
Created Nov 29, 2019
List of the 10 most repeated links on a HTML page
View TenMostRepeatedLinksOnPage.js
function duplicateLinks(document) {
const elements = Array.from(document.body.getElementsByTagName('a'));
const linkElements = elements.filter((node, index) => {
const href = node.getAttribute('href');
const isRemote = href && href.match(/^http/);
if (isRemote) {
return true;
}
});
@fgm
fgm / Check fonts on a page
Created Nov 28, 2019
Build a list of the font families and weights on a web page, with the number of elements using them
View Check fonts on a page
const nodes = document.body.getElementsByTagName('*');
const styles = {};
for (const node of nodes) {
const s = getComputedStyle(node);
if (!styles[s.fontFamily]) {
styles[s.fontFamily] = {};
}
if (!styles[s.fontFamily][s.fontWeight]) {
@fgm
fgm / List services available in Meteor app
Last active Dec 21, 2018
List the services available from all Atmosphere packages bundles in the current Meteor app
View List services available in Meteor app
console.log(Object.keys(Package).sort().map(x => ({ [x]: Object.keys(Package[x]).sort(), })))
/*
Main use case: finding the name of the actual services available when you decide to adopt a
dependency injection pattern, especially with TypeScript, and import every needed package
instead of relying on the global availability provided by the Meteor runtime for /some/ of them.
*/
@fgm
fgm / KernelCommands.php
Created Dec 19, 2017
Dump Drupal listeners, including subscribers
View KernelCommands.php
<?php
// Place in (module)/src/Commands
namespace Drupal\rdcm\Commands;
use Drush\Commands\DrushCommands;
use Robo\Common\OutputAwareTrait;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Yaml\Yaml;
@fgm
fgm / # php70 - 2016-10-28_14-44-32.txt
Created Oct 28, 2016
php70 (homebrew/php/php70) on macOS 10.12.1 - Homebrew build logs
View # php70 - 2016-10-28_14-44-32.txt
Homebrew build logs for homebrew/php/php70 on macOS 10.12.1
Build date: 2016-10-28 14:44:32
@fgm
fgm / # php70 - 2016-10-28_14-44-32.txt
Created Oct 28, 2016
php70 (homebrew/php/php70) on macOS 10.12.1 - Homebrew build logs
View # php70 - 2016-10-28_14-44-32.txt
Homebrew build logs for homebrew/php/php70 on macOS 10.12.1
Build date: 2016-10-28 14:44:32
View keybase.md

Keybase proof

I hereby claim:

  • I am fgm on github.
  • I am fgm (https://keybase.io/fgm) on keybase.
  • I have a public key whose fingerprint is 134F 30CA B7AE 45B8 E50E 7756 EC88 8C26 7F6E 6384

To claim this, I am signing this object:

@fgm
fgm / instrument.drush.inc
Created Aug 4, 2016
Drush time and memory measurement
View instrument.drush.inc
<?php
/**
* @file
* A simple Drush plugin to report on time spent and memory usage
* without all the noise from the Drush "-d" option. Results look like:
$ drush cc all
'all' cache was cleared. [success]
Duration: 3.39 seconds
Memory:
View mongodb_1.1.7_stubs.php
<?php
/**
* Stubs generated from the mongodb extension using:
* Fgm\StubGenerator\StubDumper 2.0.0
*
* Name : mongodb
* Version : 1.1.7
* INI entries : 1
* - mongodb.debug = /tmp/mongodb_php.log
*/
You can’t perform that action at this time.