Skip to content

Instantly share code, notes, and snippets.

View michaellopez's full-sized avatar

Michael Zetterberg fd. Lopez michaellopez

View GitHub Profile
terminal = require('color-terminal')
log = (error, stdout, stderr, cb) ->
if error
terminal.color('red').write stdout
else
terminal.color('green').write stdout
cb()
@michaellopez
michaellopez / var-log-messages
Created November 26, 2015 11:52
Rancher crash exception
[rancher@rancher-server ~]$ cat /var/log/messages
...
Nov 24 13:17:06 rancher sshd[3573]: Disconnected from 172.20.0.11
Nov 24 20:48:20 rancher kernel: [47826.765444] docker invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Nov 24 20:48:20 rancher kernel: [47826.766858] docker cpuset=/ mems_allowed=0
Nov 24 20:48:20 rancher kernel: [47826.767548] CPU: 1 PID: 390 Comm: docker Not tainted 4.2.3-rancher #1
Nov 24 20:48:20 rancher kernel: [47826.768488] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Nov 24 20:48:20 rancher kernel: [47826.769855] 0000000000000000 0000000000000000 ffffffff8159e913 ffff88002fdd0000
Nov 24 20:48:20 rancher kernel: [47826.771827] ffffffff8159bd05 0000000000000016 ffffffff81086352 ffffffff81a12808
Nov 24 20:48:20 rancher kernel: [47826.773281] 0000000000000016 0000000000000000 000000000003e469 0000000000000000
@michaellopez
michaellopez / keybase.md
Created February 3, 2017 08:40
Keybase proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@michaellopez
michaellopez / viewsreference_add_entity_to_context-2.patch
Last active April 12, 2018 21:43 — forked from filiphazardous/viewsreference_add_entity_to_context-2.patch
Add nodes in block to context for viewsreference v2
diff --git a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
index 7371caf..36252cf 100644
--- a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
@@ -100,6 +100,9 @@ class ViewsReferenceFieldFormatter extends FormatterBase {
}
$node = \Drupal::routeMatch()->getParameter('node');
+ if ($items->getEntity() instanceof \Drupal\node\NodeInterface) {
+ $node = $items->getEntity();
@michaellopez
michaellopez / svgo-config-svgr.json
Last active September 28, 2018 11:00
SVGO config for SVGR
{
"plugins": [
{
"removeDoctype": true
},
{
"removeXMLProcInst": true
},
{
"removeComments": true
diff --git a/src/Patches.php b/src/Patches.php
index 70c5b83..ba01d6d 100644
--- a/src/Patches.php
+++ b/src/Patches.php
@@ -8,10 +8,14 @@
namespace cweagans\Composer;
use Composer\Composer;
+use Composer\DependencyResolver\DefaultPolicy;
+use Composer\DependencyResolver\Pool;
diff --git a/field_collection.entity.inc b/field_collection.entity.inc
index 2e8a11b..ed8dfb7 100644
--- a/field_collection.entity.inc
+++ b/field_collection.entity.inc
@@ -291,24 +291,29 @@ class FieldCollectionItemEntity extends Entity {
protected function fetchHostDetails() {
if (!isset($this->hostEntityId)) {
if ($this->item_id) {
+ $in_use = $this->isInUse();
+
@michaellopez
michaellopez / sparkpost-return_path.patch
Created January 22, 2019 04:05
Patch that adds return_path / envelope FROM to Sparkpost Drupal module
diff --git a/config/install/sparkpost.settings.yml b/config/install/sparkpost.settings.yml
index e014059..504215a 100644
--- a/config/install/sparkpost.settings.yml
+++ b/config/install/sparkpost.settings.yml
@@ -2,6 +2,7 @@ api_key:
debug: true
sender:
sender_name:
+return_path:
format: ''
@michaellopez
michaellopez / readme.md
Created April 26, 2019 09:07 — forked from astoilkov/readme.md
Async Operations with useReducer Hook

Async Operations with useReducer Hook

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

Doing asynchronous operations in a useReducer reducer is not possible. We have thought of three possible solutions and can't figure which one is better or if there is an even better solution.

@michaellopez
michaellopez / output.sh
Last active October 25, 2019 15:09
now: yarn lint errors
$ yarn lint
yarn run v1.19.1
$ eslint . --ext .ts,.js
.../now/packages/now-build-utils/src/debug.ts
1:63 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
.../now/packages/now-build-utils/src/fs/glob.ts
48:30 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
49:23 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion