These are dbase files
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
/** | |
* Multi-level array flattening. Takes an array of arbitrarily deep nested arrays, and returns an array of values. | |
* It mutates the original array instead of creating a new one. | |
**/ | |
function flatten(arr) { | |
for (let i = 0, inc=1; i < arr.length; i += inc) { | |
if (Array.isArray(arr[i])) { | |
const flat = flatten(arr[i]); | |
arr.splice(i, 1, ...flat); | |
inc = flat.length; |
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
async function* fetchChunks(...args) { | |
let response = await fetch(...args); | |
let reader = response.body.getReader(), state = {done:false}; | |
while (!state.done) { | |
state = await reader.read(); | |
yield state.value; | |
} | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 python3 -m doctest | |
from __future__ import annotations | |
import typing | |
def f(clazz): | |
""" | |
>>> class MyClass: | |
... pass | |
>>> class MyOtherClass: |
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
/// An iterator where you can look back on items that were already consumed | |
struct PartiallyConsumedIterator<T, I: Iterator<Item=T>> { | |
/// Elements that were already consumed | |
previous: Vec<T>, | |
/// Elements that still have to be consumed | |
remaining: I, | |
} | |
impl<T, I: Iterator<Item=T>> From<I> for PartiallyConsumedIterator<T, I> { | |
fn from(iter: I) -> Self { |
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
use num::{One, BigUint}; // 0.2.0 | |
use std::ops::{MulAssign, AddAssign}; | |
fn fac<T>(n: T) -> T | |
where T: One + AddAssign + Ord, | |
for <'a> T : MulAssign<&'a T> { | |
let mut r = T::one(); | |
let mut i = T::one(); | |
while i <= n { |
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
/* | |
A WBO (https://wbo.openode.io) hello world script | |
This draws an orange square | |
Be careful not to commit more than a few updates per second to the server when scripting, or it will ban you. | |
Enter the following in your browser's javascript console: | |
*/ |
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
extern crate pipe; | |
/** | |
Some libraries (such as handlebars or serde) offer functions that can generate data when given | |
an object that implements io::Write. | |
Some other libraries (such as Rocket) can consume data only from objects implementing io::Read. | |
Here is an example `piper` function that can be used to make these two kinds of libraries together. |