Skip to content

Instantly share code, notes, and snippets.

View hiulit's full-sized avatar
💻
Working

hiulit

💻
Working
View GitHub Profile
@hiulit
hiulit / ajax-loop.js
Created December 19, 2016 15:57
Automatically try AJAX request again on fail
var attempts;
function doAjaxRequest() {
attempts = 0;
doAjaxRequestLoop();
}
function doAjaxRequestLoop() {
attempts += 1;
if (attempts > 10) {
alert('too many attempts.');
@hiulit
hiulit / stylus-variables-usage-with-string-interpolation.styl
Last active April 20, 2018 09:23
Stylus variables usage with string interpolation (e.g. when using the calc() function)
$some-variable = 10px
body
width: "calc(100% - %s)" % $some-variable
// To use multiple variables wrap the values into round brackets.
$some-variable = 10px
$another-variable = 5px
@hiulit
hiulit / m-keep-ratio.styl
Last active June 13, 2016 09:48
Stylus mixin to easily keep the aspect ratio.
/*
The HTML structure should be something like this:
<div class="box">
<div class="box__content">
// Images or whatever inside
</div>
</div>