Skip to content

Instantly share code, notes, and snippets.

@Minobi
Minobi / index.html
Created Oct 7, 2021
Textarea autoresize
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Textarea autoresize</title>
<style>
textarea {
resize: none;
width: 15rem;
height: 3rem;
margin: 10% 45%;
@Minobi
Minobi / fileListModify.js
Last active Oct 7, 2021
Add and remove file from non-modifying FileList in input type "file"
View fileListModify.js
function addFile(fileInput, event) {
const dt = new DataTransfer();
Array.from(fileInput.files).forEach(file => {
dt.items.add(file);
});
Array.from(event.dataTransfer.files).forEach(file => {
dt.items.add(file);
});
@Minobi
Minobi / index.py
Created May 14, 2021
Template file for running Flask in production on Repl.it with Gevent and Flask-Compress
View index.py
# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
from gevent.pywsgi import WSGIServer
from flask_compress import Compress
from flask import Flask, render_template
app = Flask(__name__)
@Minobi
Minobi / smooth.js
Last active Sep 3, 2020
Smooth scroll to anchors on click with jQuery animate
View smooth.js
$('a.page-scroll').on('click', event => {
event.preventDefault();
$('html, body').stop().animate({
scrollTop: $($(event.target).attr('href')).offset().top - 100
}, 1000, 'easeInOutExpo');
});
@Minobi
Minobi / square.css
Created Feb 28, 2020
Square div block with height equal to width
View square.css
.outer-div {
position: relative;
}
.outer-div:before {
content: "";
display: block;
padding-top: 100%;
}
@Minobi
Minobi / leaflet.init.js
Last active Nov 29, 2022
Leaflet.js initialization script with OpenStreetMap, Google, Yandex and 2GIS tile servers without using API, see in action on https://codepen.io/Minobi/pen/GRQrOQP
View leaflet.init.js
import L from 'leaflet';
const leafletMap = (mapContainer, center) => {
const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors'
});
const googleSatellite = L.tileLayer('https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
attribution: '<a http="https://google.com" target="_blank">Google</a>'
@Minobi
Minobi / .babelrc
Last active Feb 3, 2020
Babel config file for Preact
View .babelrc
{
"presets": [
"@babel/preset-env"
],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "h",
"pragmaFrag": "Fragment",