Skip to content

Instantly share code, notes, and snippets.

@arturi
arturi / uppy-xhr-upload-backend.js
Created May 22, 2020 20:04
A demo backend server for testing xhr uploads with Uppy client, created by @lakesare
const fs = require('fs');
const path = require('path');
const express = require('express');
const multer = require('multer');
const argv = require('minimist')(process.argv.slice(2));
const port = argv.port || 9999;
const fileFolderName = argv.folder || 'files';
const absolutePathToFileFolder = process.cwd() + '/' + fileFolderName;
var formidable = require('formidable')
var http = require('http')
http.createServer(function (req, res) {
const headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'OPTIONS, POST, GET',
'Access-Control-Max-Age': 2592000 // 30 days
/** add other headers as per requirement */
@arturi
arturi / index.js
Created November 7, 2016 17:20
requirebin sketch
var Uppy = require('uppy')
var uppy = new Uppy.Core({
debug: true
})
uppy.use(Uppy.DragDrop, {
target: '.drag'
})
uppy.use(Uppy.ProgressBar, {target: 'body'})
uppy.use(Uppy.Tus10, {
@arturi
arturi / esnextbin.md
Created October 27, 2016 23:12
esnextbin sketch
@arturi
arturi / index.js
Last active September 25, 2016 03:39
requirebin sketch
var Uppy = require('uppy')
var uppy = new Uppy.Core({wait: false, debug: true})
uppy
.use(Uppy.DragDrop, {target: 'body'})
.use(Uppy.Tus10, {endpoint: 'http://master.tus.io:8080/files/'})
.run()
uppy.on('core:upload-success', (fileId, url) => {
console.log(url)
@arturi
arturi / index.js
Created August 25, 2016 04:47
requirebin sketch
var tus = require('tus-js-client')
var input = document.querySelector('.myInput')
input.addEventListener("change", function(e) {
// Get the selected file from the input element
var file = e.target.files[0]
// Create a new tus upload
var upload = new tus.Upload(file, {
@arturi
arturi / dev-links.md
Last active May 14, 2017 05:18
Collection of links to cool web apps for code studying, techniques, tips and tricks
@arturi
arturi / index.js
Created March 18, 2016 21:35
requirebin sketch
var yo = require('yo-yo')
var globalState = {name: 'Artur', color: 'green'}
var el = render(globalState)
document.body.appendChild(el)
function render (state) {
return yo`
<div>
<h1>My name is ${state.name}</h1>
@arturi
arturi / index.js
Last active March 18, 2016 21:37
requirebin sketch
// Components + actions with Morphdom
var morphdom = require('morphdom')
var globalState = {name: 'Artur', color: 'green'}
var el = document.createElement('div')
el.innerHTML = render(globalState)
document.body.appendChild(el)
@arturi
arturi / darken
Created November 23, 2013 10:41
## Description Darken is a very simple javascript bookmarklet that dims brightness of you browser screen for night reading. Tested in Chrome and Safari on Mac and iOS. Darken is only able to dim content of a browser window, so the address bar and buttons will remain bright (however on an iPhone you can work around it by going full-screen). This …
javascript:(function(){document.getElementsByTagName("html")[0].style.cssText = "filter: brightness(0.4); -webkit-filter: brightness(0.4); -moz-filter: brightness(0.4); -webkit-transform: translateZ(0);";})();