Skip to content

Instantly share code, notes, and snippets.

@aircokol
aircokol / gist:1e693aea218a2b66487940180b4f79f3
Created August 1, 2022 11:25
File input with file reader
window.onload = () =>
document.getElementById('file').onchange = function (e) {
const file = e.target.files[0];
// FileReader support
if (FileReader && file) {
const fr = new FileReader();
fr.onload = () => document.getElementById('file_image').src = fr.result;
fr.readAsDataURL(file);
}
@aircokol
aircokol / add_bom_to_file.php
Last active April 1, 2022 07:42
add BOM to fix UTF-8 in Excel
<?php
$fh = fopen($filename, 'w');
//add BOM to fix UTF-8 in Excel
fputs($fh, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
@aircokol
aircokol / mysql-docker.sh
Created April 5, 2021 12:49 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
# clear system caches
sudo rm -rf /Library/Caches/*
sudo rm -rf /System/Library/Caches/*
sudo rm -rf ~/Library/Caches/*
# clear dns cache
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# clear google chrome cache
@aircokol
aircokol / easings.css
Created July 22, 2020 06:28 — forked from argyleink/easings.css
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@aircokol
aircokol / service-worker-unregister.js
Created March 18, 2020 08:17
Отключение service worker
if(window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations()
.then(function(registrations) {
for(let registration of registrations) {
registration.unregister();
}
});
}
@aircokol
aircokol / bash-commands.sh
Created October 1, 2019 17:25
Разные консольные команды
// copy files
scp -P [PORT] [user]@[server]:/var/www/html/index.html ~/Desktop
// archive files
tar -zcvf /var/www/html-backup.tar.gz /var/www/html
// extract from archive
tar -zxvf /var/www/html /var/www/html-backup.tar.gz
@aircokol
aircokol / vsc_js_snippets.json
Created April 23, 2019 06:50 — forked from bradtraversy/vsc_js_snippets.json
VSCode JavaScript Snippets
{
"Console Log": {
"prefix": "cl",
"body": "console.log($1);",
"description": "Console Log"
},
"Named Function": {
"prefix": "nfn",
"body": ["function ${1:functionName}($2) {", " $3", "}"],
"description": "Named Function"
@aircokol
aircokol / docker-help.md
Created April 23, 2019 06:48 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH