Skip to content

Instantly share code, notes, and snippets.

View mchelen's full-sized avatar

Mike Chelen (he/him) mchelen

View GitHub Profile
<?php
// assumes fieldName is a text field with 1 value
function FilterNodesByRegex($nids, $fieldName, $regex) {
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
return array_filter($nodes, function($node) use ($regex, $fieldName) {
return preg_match(
$regex,
$node->get($fieldName)->getString()
);
@mchelen
mchelen / install-backport-iwlwifi-dkms.sh
Last active September 8, 2022 08:26
How to install Intel AX200 on Ubuntu 20.04 (tested with kernel 5.4.0-33-generic)
sudo apt install backport-iwlwifi-dkms

Keybase proof

I hereby claim:

  • I am mchelen on github.
  • I am mchelen (https://keybase.io/mchelen) on keybase.
  • I have a public key ASDJLpuXNtVCcDhcu__HUqvkFkFgokGpGG6j4kVk0JcNIgo

To claim this, I am signing this object:

@mchelen
mchelen / index.js
Created February 12, 2020 15:22
ES6 Destructured Object Parameters after Prettier
greet({
greeting: "Hello",
firstName: "Jane",
lastName: "Smith",
title: "Dr."
});
function greet({ greeting, firstName, lastName, title }) {
console.log(`${greeting}, ${title} ${firstName} ${lastName}`);
}
@mchelen
mchelen / index.js
Created February 12, 2020 15:19
ES6 Destructured Object Parameters
greet({
greeting: 'Hello',
firstName: 'Jane',
lastName: 'Smith',
title: 'Dr.',
});
function greet({
greeting,
firstName,
@mchelen
mchelen / index.js
Last active January 31, 2020 20:49
Javascript ES6 String Prefix Removal 3 Ways
/*
How to remove a string prefix based on a delimiter, without knowing the length of the prefix.
#1 substr() + indexOf()
#2 string.split() + array.join()
#3 string.replace() + regex
*/
// example input
const inputString = "search_field:http://www.example.com/welcome:_visitor/index.html"
> react-scripts build
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-eslint": "10.0.3"
@mchelen
mchelen / example.sh
Last active April 5, 2019 16:18
passing cli options to npm scripts
#!/bin/sh
# if i pass CLI options to index.js like this:
npm run test -- optA
# currently results in:
echo | bunyan "optA"
@mchelen
mchelen / npm-link.md
Last active January 15, 2019 21:05
create react app (cra) jest and npm link (symlinks)
@mchelen
mchelen / README.md
Last active January 15, 2019 20:48
ts-jest symlink

Using a symlink inside node_modules breaks ts-jest

# setup code
mkdir ~/tmp
cd ~/tmp
git clone https://github.com/nestjs/typescript-starter.git
npm install