This file contains hidden or 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
const jsdom = require('jsdom'); | |
const jsdomInstance = new jsdom.JSDOM('', { | |
url: 'http://example.com/', | |
runScripts: 'outside-only', | |
}); | |
jsdomInstance.window.eval(` | |
// Make POST request to Honeybager Notice API. | |
const request = new XMLHttpRequest(); |
This file contains hidden or 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
class MyStore extends Record({ a: 0, b: List() }) { | |
constructor(values) { | |
super(values); | |
const mySelector = createSelector( | |
[(record) => record.a, (record, arg) => arg], | |
(a, arg) => a + arg | |
); | |
Object.defineProperty(this, 'mySelector', | |
Object.getOwnPropertyDescriptor(values, 'mySelector') || |
This file contains hidden or 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
import { Children, createElement } from 'react'; | |
export function replaceRenderedComponents(mappings) { | |
let componentMap; | |
if (mappings instanceof Map) { | |
componentMap = mappings | |
} else if (Array.isArray(mappings)) { | |
componentMap = new Map(mappings); | |
} else { |
This file contains hidden or 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
import { createStore } from 'redux'; | |
/** | |
* This is my attempt at creating a solution for the problem of scoping actions to specific | |
* items/entities inside of nested reducers. | |
* | |
* You can use withPath(action) to add a 'path' property to an action that defines its scope in the | |
* nested state. | |
* | |
* Then your reducers can use combineReducersWithPath() to pass an appropriately appended third |
This file contains hidden or 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
// Wrap combineReducers to pass a namespace as the third argument | |
// to each reducer, so that each reducer can know where it is in | |
// the state and accept namespaced actions targeted for it. | |
function combineReducersWithNamespace(reducers) { | |
return (state, action, namespace) => { | |
const newState = {}; | |
Object.keys(reducers).forEach(name => { | |
const reducerNamespace = namespace ? | |
namespace + '.' + name : |
This file contains hidden or 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
... | |
-- Battery level widget | |
-- Create widget to show battery level | |
batterywidget = wibox.widget.textbox() | |
-- Create timer to update widget | |
batterytimer = timer({ timeout = 30 }) | |
batterytimer:connect_signal("timeout", function() | |
local battery_info = vicious.widgets.bat("This argument doesn't seem to be used for anything.", "BAT0") | |
local battery_percentage = battery_info[2] |