This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Daniel Dunderfelt | |
* | |
* Use: $(element).toggleText("text alternative 1", "text alternative 2"); | |
*/ | |
(function($) { | |
$.fn.extend({ | |
toggleText: function(toggle1, toggle2) { | |
return this.each(function(i, ele) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use this to compare one object's properties to corresponding properties on another object. | |
* Returns true if b contains all of the properties of a with the same values. Object b | |
* can contain more properties than object a, the important thing is that the values | |
* and property names of a are found on b. Enumerable properties only! | |
*/ | |
function compare(a, b) { | |
var isEqual = []; | |
var keys = Object.keys(a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Usage: generateArray(10) | |
* Where 10 is the maximum allowed length (and value range) of the array. | |
* | |
* Example output: [5, 3, 9, 1, 0, 2] | |
* | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function safe($array) | |
{ | |
return function($key, $fallback) use ($array) | |
{ | |
if(!is_array($key)) | |
{ | |
return isset($array[$key]) ? $array[$key] : $fallback; | |
} | |
if(!isset($array[$key[0]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* App creator */ | |
import { extendObservable } from 'mobx' | |
import AppStore from '../app/AppStore' | |
export default (initialState = false) => { | |
const stores = { | |
App: AppStore | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* PROBLEM: | |
* In next.js, each route points to a distinct top-level component. | |
* Since there is no higher-level components in next.js, how to have | |
* a store that persists between route changes is not immediately | |
* obvious. One solution is this: a higher-order component that you | |
* wrap each of your top-level route components with. | |
* | |
* This is borrowed from next.js' Redux example from here: | |
* https://github.com/zeit/next.js/wiki/Redux-example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am danieldunderfelt on github. | |
* I am ddunderfelt (https://keybase.io/ddunderfelt) on keybase. | |
* I have a public key whose fingerprint is 5548 BD67 2A79 92E1 530F 1A25 46CF C630 C47E 05E9 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple router for switching between hash stings. | |
* Suitable for MobX/Redux architecture and especially | |
* handy for tabs, which is the reason why it exists. | |
const state = { currentTab: 'lions' } | |
function activateTab(tabName) { | |
// Dispatch state change | |
state.currentTab = tabName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This router depends on the history package: | |
yarn add history | |
Simple router for switching between routes. Based on | |
[hashrouter.js](https://gist.github.com/danieldunderfelt/4d016333a947764c1a5687d26d48ca27) | |
Suitable for MobX/Redux architecture and especially | |
handy for tabs, which is the reason why it exists. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Future versions of Hyper may add additional config options, | |
// which will not automatically be merged into this file. | |
// See https://hyper.is#cfg for all currently supported options. | |
module.exports = { | |
config: { | |
// Choose either "stable" for receiving highly polished, | |
// or "canary" for less polished but more frequent updates | |
updateChannel: 'canary', |
OlderNewer