Skip to content

Instantly share code, notes, and snippets.

View maurobringolf's full-sized avatar
⛰️

Mauro Bringolf maurobringolf

⛰️
  • Zürich, Switzerland
View GitHub Profile
class myComponent extends React.Component {
constructor() {
super()
// Replace existing method with hardbound version of it
this.someMethod = someMethod.bind(this)
}
someMethod() {
// Do something that relies on 'this'
function find(arr, fn) {
 return arr.reduce((acc, item) => fn(item) ? acc || item : acc, undefined)
}
function map(arr, fn) {
 return arr.reduce((acc, item) => […acc, fn(item)], [])
}
function filter(arr, fn) {
 return arr.reduce((acc, item) => fn(item) ? […acc, item] : acc, [])
}
#!/usr/bin/env bash
git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | xargs git branch -D
#!/usr/bin/env bash
git branch | grep -v "^*" | xargs git branch -D