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
The MIT License (MIT) | |
Copyright (c) 2014 Dave Mackintosh | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to | |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: |
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
<ifModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule (.*) /index.html [QSA,L] | |
</ifModule> |
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
db.currentOp().inprog.forEach(function(op) { | |
if (op.progress) { | |
var remaining = op.progress.total - op.progress.done; | |
var running_for = op.secs_running / 60 / 60; | |
print(op.ns, op.opid, 'running for', running_for.toPrecision(4), 'hours') | |
print('job "'+ op.insert.name +'" running in background?', op.insert.background ? 'yes' : 'no'); | |
print(op.msg) | |
print('Remaining records', remaining, 'finished', op.progress.done, 'docs') | |
print('Estimated', ((running_for / op.progress.done) * remaining).toPrecision(4), 'hours remaining') |
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
var op = db.currentOp().inprog[0]; | |
var persec = op.progress.done / op.secs_running; | |
var time = ((op.progress.total - op.progress.done) / persec) / 60 / 60; | |
var unit = 'hours'; | |
if (time < 1.0 && time > 0.0) { | |
unit = 'minutes'; | |
time = 60 * time; | |
} |
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
package model | |
import ( | |
"fmt" | |
"io" | |
"os" | |
"github.com/go-gl/mathgl/mgl32" | |
) |
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
atom-text-editor { | |
background-color: rgb(251, 244, 239); | |
&::shadow { | |
.gutter { | |
background-color: rgb(251, 244, 239); | |
} | |
.gutter, | |
.comment, |
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
class Person { | |
constructor(name) { this.name = name.toString() } | |
be_polite() { return `Good morning, ${this.name}.` } | |
be_rude() { return `Actually, Jump off of something high.` } | |
} | |
const me = new Person("Dave") | |
me | |
|> be_polite | |
|> be_rude |
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 blob_to_buffer(blob, callback) { | |
// Create a file reader instance. | |
const file_reader = new FileReader() | |
// Listen to when reading is finished and | |
// run the callback with a buffer. | |
file_reader.addEventListener("loadend", event => { | |
if (event.error) { | |
callback(event.error) | |
} |
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
/** | |
* Convert a `Map` to a standard | |
* JS object recursively. | |
* | |
* @param {Map} map to convert. | |
* @returns {Object} converted object. | |
*/ | |
function map_to_object(map) { | |
const out = Object.create(null) | |
map.forEach((value, key) => { |
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 strict" | |
// used in benchmarks. | |
const SAMPLE = 5000000 | |
const Hoek = require('hoek') | |
const array = [] | |
for (let i = 0; i < SAMPLE; ++i) { | |
array.push(i * Math.floor(Math.random() * (10 - 1 + 1)) + 1) | |
} |