Skip to content

Instantly share code, notes, and snippets.

View fgm's full-sized avatar

Frédéric G. MARAND fgm

View GitHub Profile
@fgm
fgm / keybase.md
Created September 17, 2016 17:28

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 / # php70 - 2016-10-28_14-44-32.txt
Created October 28, 2016 13:48
php70 (homebrew/php/php70) on macOS 10.12.1 - Homebrew build logs
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 October 28, 2016 13:48
php70 (homebrew/php/php70) on macOS 10.12.1 - Homebrew build logs
Homebrew build logs for homebrew/php/php70 on macOS 10.12.1
Build date: 2016-10-28 14:44:32
@fgm
fgm / Symfony2 GraphvizDumper demo
Last active November 18, 2017 17:14
Demonstrate how to use the GraphViz Dumper in a Symfony 2.4 project.
<?php
/**
* @file
* gvdump.php
*
* @author: Frédéric G. MARAND <fgm@osinet.fr>
*
* @copyright (c) 2014 Ouest Systèmes Informatiques (OSInet).
*
* @license MIT
@fgm
fgm / KernelCommands.php
Created December 19, 2017 14:34
Dump Drupal listeners, including subscribers
<?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 / tinytest.api.js
Last active July 25, 2018 07:48 — forked from stbaer/tinytest.api
Meteor tinytest api
// From 1.1.03 packages/tinytest/tinytest.js
test._stringEqual(actual, expected, message) // Source comment: EXPERIMENTAL nicer (multiline) string display in runner
test.equal(actual, expected, message, not) // Source comment: "XXX eliminate 'message' and 'not' arguments"
/* Call this to fail the test with an exception. Use this to record exceptions
* that occur inside asynchronous callbacks in tests. It should only be used
* with asynchronous tests, and if you call this function, you should make
* sure that
* (1) the test doesn't call its callback (onComplete function);
* (2) the test function doesn't directly raise an exception.
*/
@fgm
fgm / List services available in Meteor app
Last active December 21, 2018 10:27
List the services available from all Atmosphere packages bundles in the current 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 / Check fonts on a page
Created November 28, 2019 14:52
Build a list of the font families and weights on a web page, with the number of elements using them
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 / TenMostRepeatedLinksOnPage.js
Created November 29, 2019 11:10
List of the 10 most repeated links on a HTML page
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 / HostsReferencedInPage.js
Created December 20, 2019 12:12
List the hosts referenced on a HTML page (href, src), by decreasing occurrence count
/**
* 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") {