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
document.addEventListener('paste', e => { | |
const file = e.clipboardData.items[0].getAsFile(); | |
if (!file.type.startsWith('image')) return; | |
const imgEl = new Image(); | |
const reader = new FileReader(); | |
imgEl.style.maxWidth = '100%'; | |
reader.onload = e => { |
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
import psycopg2 | |
connection = psycopg2.connect("dbname=name-of-db user=prod password=xxxx host=somehost sslmode=verify-full sslrootcert=/usr/local/share/ca-certificates/ca-2019-root.pem") |
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 scroller = (function () { | |
var startAnimation = function(duration) { | |
var startLocation = document.body.scrollTop || document.documentElement.scrollTop; | |
var startTime = Date.now(); | |
var animationID; | |
var easeInOutCubic = function(time) { | |
return time < 0.5 ? | |
4 * time * time * time : | |
(time - 1) * (2 * time - 2) * (2 * time - 2) + 1; |
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 Observer { | |
constructor(observerCallbacks) { | |
this._observerCallbacks = observerCallbacks; | |
} | |
start(subscriptionFn) { | |
return subscriptionFn(this); | |
} | |
next(...args) { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Enjoy fun animations on Web</title> | |
<style type="text/css" media="screen"> | |
:root { | |
min-height: 100%; | |
font-size: 1em; | |
} |
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
const validImageMimes = { | |
jpg: 'image/jpeg', | |
jpeg: 'image/jpeg', | |
png: 'image/png', | |
webp: 'image/webp' | |
}; | |
const svgDocHeader = `<?xml version="1.0" standalone="no"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`; |
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
#!/usr/bin/env bash | |
USER="$1" | |
SERVER_HOST="$2" | |
SOCKS_PORT="$3" | |
eval $(ssh-agent) | |
ssh-add "$HOME/.ssh/*.pem" | |
nohup ssh -CND "$SOCKS_PORT" "$USER"@"$SERVER_HOST" & |
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
import $ from 'jquery'; | |
const BootstrapSwipeCarousel = (() => { | |
const NAME = 'swipeCarousel'; | |
const CAROUSEL_DATA_KEY = 'bs.carousel.swipe2'; | |
const MIN_SPEED_TO_SLIDE = 200; // pixel per second | |
const DEBOUNCE_TIMEOUT = 40; // Magic number (it works and avoids extra slides per taps) | |
const shouldSlide = (deltaX, speed, threshold) => ( | |
Math.abs(deltaX) >= threshold |
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
/** | |
* Chaining immutable style changer | |
* Do not define any events on the element using addEventLister | |
* Use event delegation (do the parents) | |
* @param {String} name [description] | |
* @param {String} value [description] | |
* @return {Element} | |
*/ | |
Element.prototype.css = function(name, value) { | |
const parentEl = this.parentNode; |