require 'sinatra'
get '/' do
'Hello world!'
end
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 urlBase64ToUint8Array(base64String) { | |
const padding = '='.repeat((4 - base64String.length % 4) % 4); | |
const base64 = (base64String + padding) | |
.replace(/\-/g, '+') | |
.replace(/_/g, '/') | |
; | |
const rawData = window.atob(base64); | |
return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0))); | |
} |
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 a = ["sdfdf", "http://oooooolol"], | |
handleNetErr = function(e) { return e }; | |
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr)) | |
.then(function(sdf, invalid) { | |
console.log(sdf, invalid) // [Response, TypeError] | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}) |
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
XLSX file, 1.5 Mb, 10 000 rows | |
================================== | |
Benchmark.measure { ::Creek::Book.new(import.import_file.read.path).sheets.first.rows.first } | |
<Benchmark::Tms:0x0000010eb1b200 | |
@cstime=0.0, | |
@cutime=0.0, | |
@label="", | |
@real=83.360489, |
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
public static void downloadFile(final Long fileId) throws IOException { | |
response.setHeader("Accept-Ranges", "bytes"); | |
notFoundIfNull(fileId); | |
File underlyingFile = ... //load file | |
String fileName = ...//name of the file | |
Header rangeHeader = request.headers.get("range"); | |
if (rangeHeader != null) { | |
throw new PartialContent(underlyingFile, fileName); |