Skip to content

Instantly share code, notes, and snippets.

View saginadir's full-sized avatar
:octocat:

Sagi saginadir

:octocat:
View GitHub Profile
@saginadir
saginadir / keep_ratio.js
Last active September 12, 2016 07:39
Sometimes it's needed to keep a ratio of an image/canvas but still display it in a middle of a div that might not be the same ratio of the image/canvas, this function returns the new size of the image/canvas to cover the div, with negative margins for top/left if needed.
let myDiv = $('.stage');
let myImage = $('.stage img');
let stage = {
width: myDiv.width(),
height: myDiv.height(),
}
let item = {
width: myImage.width(),
@saginadir
saginadir / new_ebs_ec2.md
Last active February 25, 2016 10:15
Attache new EBS to instance after it was created