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
| #!/usr/bin/env bash | |
| usage() { | |
| cat <<EOF | |
| Usage: $0 VOLUME [VOLUME ...] | |
| Restore Docker volumes from tar archives. | |
| EOF | |
| } |
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
| #!/usr/bin/env bash | |
| usage() { | |
| cat <<EOF | |
| Usage: $0 VOLUME [VOLUME ...] | |
| Back up Docker volumes to tar archives. | |
| EOF | |
| } |
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
| -- Adapted from http://coussej.github.io/2015/09/15/Listening-to-generic-JSON-notifications-from-PostgreSQL-in-Go/ | |
| CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS $$ | |
| DECLARE | |
| data JSON; | |
| notification JSON; | |
| BEGIN | |
| -- Skip notification if row doesn't actually change in UPDATE. | |
| -- We can accomplish the same thing with a WHERE clause in the CREATE TRIGGER statement, | |
| -- but only if the trigger watches exclusively for UPDATE events. |
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
| // Usage: | |
| // | |
| // const YourComponent = ({ activePageHash }) => ... | |
| // export default withHashRouter(YourComponent, ['#valid-page-1', '#valid-page-2']); | |
| import { Component, createElement as h } from 'react'; | |
| // Falls back to the initial page if the hash specifies an unknown one. | |
| function replaceHashWithValidPage(validPageHashes) { | |
| if (!validPageHashes) { |
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
| function groupBy(values, key) { | |
| return values.reduce((accumulator, value) => { | |
| const id = value[key]; | |
| accumulator[id] = accumulator[id] || []; | |
| accumulator[id].push(value); | |
| return accumulator; | |
| }, {}); | |
| } |
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
| // Usage: | |
| // | |
| // const SSE = require('./sse'); | |
| // const sse = new SSE(); | |
| // ... | |
| // app.get('/updates', sse.routeHandler); | |
| // ... | |
| // sse.send('Some string', 'some-event-name'); | |
| const { EventEmitter } = require('events'); |
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
| #!/usr/bin/env bash | |
| # Watches a file and prints when a specified variable value changes. | |
| # We assume the file is a list of key=value pairs separated by newlines. | |
| if [ $# -ne 2 ]; then | |
| echo "Usage: $0 FILE KEY" | |
| exit 1 | |
| fi |
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
| auto isClient = GEngine->GetNetMode(GetWorld()) == NM_Client); |