Skip to content

Instantly share code, notes, and snippets.

@hasdavidc
hasdavidc / storagePolyfill.js
Last active Jun 9, 2020
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)
View storagePolyfill.js
//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");
@hasdavidc
hasdavidc / webcamImagesToGif-poc.js
Last active Aug 29, 2015
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
View webcamImagesToGif-poc.js
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>POC</title>
<style>
#canvas {
display: none;
}
</style>
@hasdavidc
hasdavidc / webcamVideoToGif-poc.js
Created Jan 30, 2014
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
View webcamVideoToGif-poc.js
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>POC</title>
<style>
#canvas {
display: none;
}
</style>
@hasdavidc
hasdavidc / metaSlider.php
Created Mar 14, 2014
pertinent get_slides
View metaSlider.php
<?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 / yo.html
Created Aug 3, 2014
My Yo web clone in React and Firebase, using Twitter authentication
View yo.html
<!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>
View storeListenerMixin.es6.js
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 / ace.jsx
Created Sep 11, 2015
modified react-ace editor; prefer componentDidUpdate over componentWillReceiveProps; destroy in the componentWillUnmount
View ace.jsx
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,
@hasdavidc
hasdavidc / autobind-potential-bug.js
Created Sep 28, 2015
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
View autobind-potential-bug.js
import { autobind } from 'lib/decorators';
class AwesomeClass {
@autobind
awesomeMethod() {
console.log('parent called, AWESOME METHOD');
}
}