Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
import wait from './wait';
//...
save(formData) {
//...
upload(formData)
.then(wait(1500)) // DEV ONLY: wait for 1.5s
.then(x => {
this.uploadedFiles = [].concat(x);
@andreasvirkus
andreasvirkus / easings.js
Last active September 22, 2017 14:16
A snippet to smoothly scroll to elements
export const easings = {
linear(t) {
return t;
},
easeInQuad(t) {
return t * t;
},
easeOutQuad(t) {
return t * (2 - t);
},
export const serve = (path, cache) => express.static(resolve(path), {
maxAge: cache && isProd ? 60 * 60 * 24 * 30 : 0
})
@andreasvirkus
andreasvirkus / resize.js
Last active September 14, 2017 12:26 — forked from arturparkhisenko/resize.js
resize and throttle with rAF
//https://developer.mozilla.org/en-US/docs/Web/Events/resize
(function() {
var throttle = function(type, name, obj_) {
var obj = obj_ || window;
var running = false;
var func = function() {
if (running) {
return;
}
.brdr-envelope {
background-image: url(envelope-border.png);
background-position: 0 100%;
background-repeat: repeat-x;
background-size: 40px 3px;
}
@andreasvirkus
andreasvirkus / .env
Created September 12, 2017 11:43
Running npm scripts with env variables; the comfy way.
NODE_ENV=development
@andreasvirkus
andreasvirkus / pullGitBoilerplate.sh
Created August 19, 2017 07:56
Sometimes you wish to pull in a boilerplate for your gh-pages branch.
export REPO_NAME=repo
export RELEASE=release-or-branch
curl -L https://github.com/user-or-org/$REPO_NAME/archive/$RELEASE.tar.gz | tar xz \
&& mv $REPO_NAME-$RELEASE/* ./
@andreasvirkus
andreasvirkus / common.conf
Last active January 3, 2019 15:14
Just an Nginx configuration
# Config to disallow the browser to render the page inside an iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# don't send the nginx version number in error pages and Server header
server_tokens off;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
@andreasvirkus
andreasvirkus / cash.jquery.js
Created August 15, 2017 14:48
Cash.js script that also pretends to be jQuery (for those stubborn jQuery plugins)
"use strict";/*! cash-dom 1.3.0, https://github.com/kenwheeler/cash @license MIT */
!function(t,n){"function"==typeof define&&define.amd?define(n):"undefined"!=typeof exports?module.exports=n():t.cash=t.$=n()}(this,function(){function t(t,n){n=n||w;var e=k.test(t)?n.getElementsByClassName(t.slice(1)):F.test(t)?n.getElementsByTagName(t):n.querySelectorAll(t);return e}function n(t){return E=E||w.createDocumentFragment(),A=A||E.appendChild(w.createElement("div")),A.innerHTML=t,A.childNodes}function e(t){"loading"!==w.readyState?t():w.addEventListener("DOMContentLoaded",t)}function r(r,i){if(!r)return this;if(r.cash&&r!==T)return r;var o,u=r,s=0;if(q(r))u=$.test(r)?w.getElementById(r.slice(1)):D.test(r)?n(r):t(r,i);else if(R(r))return e(r),this;if(!u)return this;if(u.nodeType||u===T)this[0]=u,this.length=1;else for(o=this.length=u.length;o>s;s++)this[s]=u[s];return this}function i(t,n){return new r(t,n)}function o(t,n){for(var e=t.length,r=0;e>r&&n.call(t[r],t[r],r,t)!==!1;r++);}function u(t,n){var e=t&&(t.matche
.fade-gradient {
position: fixed;
top: 100px;
height: 100px;
width: 100%;
background-image: url(gradient.png);
margin: 0;
left: 0;
}