Skip to content

Instantly share code, notes, and snippets.

View tw15egan's full-sized avatar

TJ Egan tw15egan

View GitHub Profile
@Restuta
Restuta / the-bind-problem.jsx
Last active March 16, 2024 00:22
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
@orrybaram
orrybaram / listenWithMe.js
Last active July 31, 2016 20:54
Add an embedded spotify player that plays the track your currently listening to (or last listened to) Demo at http://orryb.com/projects/currentSpotify/
var ListenWithMe = (function() {
// Add your own config here
var LASTFM_API_KEY = "";
var LASTFM_USERNAME = "";
// Element to inject the widget into
var $playerWrapper = document.getElementById('spotify-player-wrapper');
return {
init: init
}