Skip to content

Instantly share code, notes, and snippets.

View danb-humaan's full-sized avatar

Dan Barrett danb-humaan

  • Humaan
  • Perth, Australia
View GitHub Profile
@danb-humaan
danb-humaan / get_commit_hash.php
Created October 10, 2016 05:41
Helper function to get a git commit hash from a few sources.
<?php
if (!function_exists('get_commit_hash')) {
/**
* Checks to see if we have a .commit_hash file or .git repo and return the hash if we do.
*
* @return null|string
*/
function get_commit_hash()
{
var ls = require('lib/LocalStorage');
// These examples assume you are using jQuery for AJAX calls.
// Closure usage
ls.getItem('devices', function(devices) {
if (devices === null) {
$.ajax({
url: '/data/devices.json',
dataType: 'json',
method: 'get'
removeItem: function (key) {
if (this.supportsLocalStorage()) {
localStorage.removeItem(key);
}
}
/**
* Fetches the value associated with key from localStorage. If the key/value aren't in localStorage, you can optional provide a callback to run as a fallback getter.
* The callback will also be run if the localStorage cache has expired. You can use {@link LocalStorage#setItem} in the callback to save the results from the callback back to localStorage.
*
* @example <caption>Fetch from localStorage with no callback and get the response returned.</caption>
* var response = LocalStorage.getItem('key');
*
* @example <caption>Fetch from localStorage and handle response in a callback.</caption>
* LocalStorage.getItem('key', function(response) {
* if (response === null) {
/**
* Saves an item in localStorage so it can be retrieved later. This method automatically encodes the value as JSON, so you don't have to. If you don't supply a value, this method will return false immediately.
*
* @example <caption>set localStorage that persists until it is manually removed</caption>
* LocalStorage.setItem('key', 'value');
*
* @example <caption>set localStorage that persists for the next 30 seconds before being busted</caption>
* LocalStorage.setItem('key', 'value', 30);
*
* @kind function
/**
* Determines whether the browser supports localStorage or not.
*
* This method is required due to iOS Safari in Private Browsing mode incorrectly says it supports localStorage, when it in fact does not.
*
* @kind function
* @function LocalStorage#supportsLocalStorage
*
* @returns {boolean} Returns true if setting and removing a localStorage item is successful, or false if it's not.
*/
"images": {
"low_resolution": {
"url": "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s320x320/e35/1172990_1289634271062707_99066703_n.jpg",
"width": 320,
"height": 276
},
"thumbnail": {
"url": "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e35/c73.0.934.934/1172990_1289634271062707_99066703_n.jpg",
"width": 150,
"height": 150
"images": {
"low_resolution": {
"url": "https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s320x320/e35/12338585_1668903330056644_140182574_n.jpg",
"width": 320,
"height": 320
},
"thumbnail": {
"url": "https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e35/12338585_1668903330056644_140182574_n.jpg",
"width": 150,
"height": 150
{
"name": "humaan-demo-webpack-react-app",
"version": "1.0.0",
"description": "A basic environment for writing React apps in ES6 and built using webpack",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"webpack-server": "webpack-dev-server --hot --progress --colors",
"web-server": "http-server -p 3000 .",
"start": "npm run webpack-server & npm run web-server"
module.exports = {
entry: getEntrySources(['./src/js/entry.js']),
output: {
publicPath: 'http://localhost:8080/',
filename: 'build/bundle.js'
},
devtool: 'eval',
module: {
preLoaders: [
{