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
import androidx.lifecycle.SavedStateHandle | |
import kotlinx.coroutines.flow.MutableStateFlow | |
private class SavingFlow<T> private constructor( | |
private val save: (T) -> Unit, | |
private val msf: MutableStateFlow<T> | |
) : | |
MutableStateFlow<T> by msf { | |
constructor( |
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
#pragma METAINFO("Zuiki Densha-de-GO! for PS4", 1, 0, "Wes Alvaro") | |
// Converts NS Zuiki Densha-de-GO! controller mascon values for PS4. | |
// Mascon values need conversion or else mascon positions are skipped. | |
// No changes are needed for other controls (including EB). | |
// Controls should be set to 「スタンダード」"Standard" + 「ダイレクト」"Direct". | |
#include <switch.gph> | |
// The mascon is controlled with the left analog stick's y-axis. | |
// Values are negative for braking, positive for powering, 0 when neutral. |
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
@font-face{ | |
font-family: 'Fira Code'; | |
src: url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/eot/FiraCode-Regular.eot') format('embedded-opentype'), | |
url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff2/FiraCode-Regular.woff2') format('woff2'), | |
url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff/FiraCode-Regular.woff') format('woff'), | |
url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/ttf/FiraCode-Regular.ttf') format('truetype'); | |
font-weight: normal; | |
font-style: normal; | |
} |
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
/** | |
* Converts a function from a callback API to a Promise API. | |
* | |
* Example: | |
* const context = navigator.geolocation; | |
* const f = context.getCurrentPosition; | |
* const getCurrentPosition = promisify(f, 0, 1, context); | |
* const enableHighAccuracy = true; | |
* getCurrentPosition({enableHighAccuracy}) | |
* .then(r => console.log(r.coords), e => console.error(e)); |
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 dowdiff() { | |
wdiff \ | |
-w $'\e[91m' \ | |
-x $'\e[0m' \ | |
-y $'\e[92m' \ | |
-z $'\e[0m' \ | |
$1 $2 | |
} | |
function findwdiff() { | |
local diff=$(mktemp /tmp/wdiff-full.XXXXX) |
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
/** | |
* Citizen Parent Clock Program | |
* Send an alternating polarity 24V signal to a child clock every 30 seconds. | |
* This will tick the clock half and full minutes via its internal electromagnet. | |
*/ | |
#define TICK_LENGTH_MS 500 | |
#define CHILD_CLOCK_TICK_INTERVAL 30000 // 30 Seconds | |
#define STATE_SLEEP 0 // No power signal |
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
const extendGoogleVisualization = () => { | |
const dataView = google.visualization.DataView.prototype; | |
const dataTable = google.visualization.DataTable.prototype; | |
dataView.getNiceRow = dataTable.getNiceRow = function(r) { | |
const row = []; | |
for (let c = 0; c < this.getNumberOfColumns(); ++c) { | |
const colId = this.getColumnId(c); | |
row.push(this.getValue(r, c)); | |
if (colId) { | |
row[colId] = row[c]; |
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
const pipe = (...tasks) => { | |
const dominos = []; | |
const fellDomino = () => { | |
setTimeout(() => { | |
if (!dominos.length) return; | |
dominos.pop()(); | |
}, 0); | |
}; | |
tasks.forEach((task, i) => { | |
dominos.unshift(() => { |
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
#/bin/sh | |
mkdir -p /tmp/weather | |
if [ -n "$1" ]; then | |
echo "Deleting old images." | |
rm -rf /tmp/weather/* | |
fi | |
cd /tmp/weather | |
SECS=`date "+%s"` | |
NUM_FRAMES="50" | |
while [ $NUM_FRAMES -gt 0 ]; do |
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
const it = function(a) { | |
return new Aarray(a2g(a)); | |
}; | |
const a2g = function*(a) { | |
for (let v of a) { | |
yield v; | |
} | |
}; |
NewerOlder