This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Insert doc: | |
sections = [ | |
{ | |
slug:"introduction", | |
title:"Introduction", | |
videos:[ | |
{"k": "v0"}, | |
{"k": "v1"}, | |
{"_id": ObjectId('abcdefghijkl')} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package isdebugging | |
import ( | |
"os" | |
"github.com/mitchellh/go-ps" | |
) | |
// IsDebugging will return true if the process was launched from Delve or the | |
// gopls language server debugger. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Drupal\upgrade_status; | |
/** | |
* CheckedResult provides a format to return both a result and an error. | |
* | |
* When the error is not NULL, the result is to be ignored | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Build a commit frequency list. | |
ROW_LIMIT=20 | |
git log --name-status $* | \ | |
grep -E '^[A-Z]\s+' | \ | |
cut -c3-500 | \ | |
sort | \ | |
uniq -c | \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
*/ |
NewerOlder