Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am alexrussell on github.
  • I am alexrussell (https://keybase.io/alexrussell) on keybase.
  • I have a public key ASDAHeM-gBzZH8uAGNY7UfaVDFtzZOW4KwN638NNVTu9oQo

To claim this, I am signing this object:

@alexrussell
alexrussell / navSaga.js
Created November 15, 2017 12:43
Idea of how I have implemented a `goBackTo` saga for react-navigation.
export const goBackTo = function * goBackTo ({ payload: { routeName } }) {
const { nav } = yield select()
let targetIndex
for (let i = nav.index; i > 0; i--) {
if (nav.routes[i].routeName === routeName) {
targetIndex = i + 1
break
}
@alexrussell
alexrussell / OutsideEventListener.js
Last active October 27, 2016 14:55
Outside event listener HOC
export default function OutsideEventListener(Target, listeners = []) {
return class OutsideEventListener extends Component {
target = null
componentDidMount() {
for (const eventName of listeners) {
window.addEventListener(eventName, this.handleEvent, false)
}
}
@alexrussell
alexrussell / gist:4195904
Created December 3, 2012 15:54
Wikify Bookmarklet
javascript:(function(){var els = document.querySelectorAll('p'), df, quotes=['I reckon that','My mate told me','I heard in the pub that','My mum told me','My nana always said that','According to the Daily Mail,','Common sense dictates that','Some people say','Apparently,','I read on Wikipedia that']; for (var element in els) { df = document.createElement('span'); df.innerHTML = quotes[Math.floor(Math.random() * quotes.length)] + ' '; els[element].insertBefore(df, els[element].childNodes[0]); };})();