Skip to content

Instantly share code, notes, and snippets.

View macklinu's full-sized avatar

Mackie Underdown macklinu

View GitHub Profile
const isNbaBasketball = matches({
type: 'basketball',
ballColor: 'orange',
ballMaker: /spalding/i,
'league.type': 'NBA'
})
↓ ↓ ↓ ↓ ↓ ↓
const isNbaBasketball = arg => {
┬─┬ ノʕ•ᴥ•ノʔ
ʕノ•ᴥ•ʔノ ︵ ┻━┻
/@
__ __ /\/
/==\ / \_/\/
/======\ \/\__ \__
/==/\ /\==\ /\_|__ \
/==/ || \=\ / / / /_/
/=/ /\ || /\ \=\/ /
/===/ / \||/ \ \===\
/===/ /_________________ \===\

Performs the following codemod:

- if (module.hot) {
-   // any code inside the if statement
- }

To run, execute the following command:

Benchmarking the code change in gatsbyjs/gatsby#7909

Example results on my machine:

//  Model Name:	MacBook Pro
//  Model Identifier:	MacBookPro14,3
//  Processor Name:	Intel Core i7
//  Processor Speed:	2.8 GHz
//  Number of Processors:	1
var person = {
name: "Ben",
print: function() {
var self = this;
console.log(this.name);
(function() {
console.log(this.name);
console.log(self.name);
@macklinu
macklinu / README.md
Last active May 17, 2018 18:07
Convert object methods to shorthand syntax

jscodeshift codemod that converts object shorthand syntax

// from this
const person = {
  name: function() {
    return this.firstName + " " + this.lastName;
  }
};

Keybase proof

I hereby claim:

  • I am macklinu on github.
  • I am macklinu (https://keybase.io/macklinu) on keybase.
  • I have a public key ASAMbL_iUc1j5NraqETRUntD7KTF9IK-itXqz80T0WFARgo

To claim this, I am signing this object:

@macklinu
macklinu / README.md
Last active August 29, 2015 14:26
A Checkstyle checks counter

Checkstyle Violation Counter

A short script to count Checkstyle violation types.

Usage

$ ruby xml.rb /path/to/checkstyle-results.xml