Skip to content

Instantly share code, notes, and snippets.

@hasdavidc
hasdavidc / autobind-potential-bug.js
Created September 28, 2015 23:08
I don't think I'm doing anything blatantly wrong, but after memoization kicks in, subsequent calls to the child class's method end up skipping to the parent
import { autobind } from 'lib/decorators';
class AwesomeClass {
@autobind
awesomeMethod() {
console.log('parent called, AWESOME METHOD');
}
}
@hasdavidc
hasdavidc / ace.jsx
Created September 11, 2015 18:45
modified react-ace editor; prefer componentDidUpdate over componentWillReceiveProps; destroy in the componentWillUnmount
var ace = require('brace');
var React = require('react');
module.exports = React.createClass({
displayName: 'ReactAce',
propTypes: {
mode : React.PropTypes.string,
theme : React.PropTypes.string,
name : React.PropTypes.string,
var StoreListenerMixin = function(...stores) {
var StoreMixin = {
getInitialState() {
return this.getStateFromStores(this.props);
},
componentDidMount() {
stores.forEach(store => store.addChangeListener(this.handleStoresChanged));
this.setState(this.getStateFromStores(this.props));
@hasdavidc
hasdavidc / yo.html
Created August 3, 2014 07:42
My Yo web clone in React and Firebase, using Twitter authentication
<!DOCTYPE html>
<head>
<!-- React JS -->
<script src="http://fb.me/react-0.10.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.10.0.js"></script>
<!-- Firebase JS -->
<script src="https://cdn.firebase.com/js/client/1.0.17/firebase.js"></script>
<!-- Firebase Login JS -->
<script src="https://cdn.firebase.com/js/simple-login/1.6.1/firebase-simple-login.js"></script>
@hasdavidc
hasdavidc / metaSlider.php
Created March 14, 2014 07:45
pertinent get_slides
<?php
/**
* The main query for extracting the slides for the slideshow
*/
public function get_slides() {
$args = array(
'force_no_custom_order' => true,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_type' => 'attachment',
@hasdavidc
hasdavidc / webcamVideoToGif-poc.js
Created January 30, 2014 05:14
A Proof of Concept using the Animated-GIF and gumhelper libraries from @sole in which a webcam stream is converted into a GIF; Requires the Animated_GIF and gumhelper folder paths to actually work
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>POC</title>
<style>
#canvas {
display: none;
}
</style>
@hasdavidc
hasdavidc / webcamImagesToGif-poc.js
Last active August 29, 2015 13:55
A Proof of Concept using the Animated-GIF library from @sole in which webcam images are converted into a GIF; Requires the Animated_GIF folder path to actually work
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>POC</title>
<style>
#canvas {
display: none;
}
</style>
@hasdavidc
hasdavidc / storagePolyfill.js
Last active June 9, 2020 20:55
A LocalStorage polyfill that also works in private browsing Safari (by doing window.localStorage.__proto__ = ourPolyfillObject) (where window.localStorage !== 'undefined', but has a quota of 0 and throws an error when you try to setItem)
//variant of https://gist.github.com/Contra/6368485
(function () {
var isStorageAvailable = function (storage) {
if (typeof storage == 'undefined') return false;
try { // hack for safari incognito
storage.setItem("storage", "");
storage.getItem("storage");
storage.removeItem("storage");