Skip to content

Instantly share code, notes, and snippets.

View renarsvilnis's full-sized avatar
🌊

Renārs Vilnis renarsvilnis

🌊
View GitHub Profile
alert('Hello world!');

Keybase proof

I hereby claim:

  • I am renarsvilnis on github.
  • I am renarsvilnis (https://keybase.io/renarsvilnis) on keybase.
  • I have a public key ASCqW6nmRyxAuawicthyZFzwvp-FVybO76yYRTzLcdfr7go

To claim this, I am signing this object:

// ...
function loggingMiddleware (req, res, next) {
const id = genReqId(req)
req.log = res.log = logger.child({reqId: id})
req.log[useLevel]({req}, 'Recieved request')
res[startTime] = res[startTime] || Date.now()
if (!req.res) { req.res = res }
res.on('finish', onResFinished)
@renarsvilnis
renarsvilnis / DelayMount.js
Last active April 4, 2017 20:10
<DelayMount/> component
import {PureComponent, PropTypes} from 'react';
export default class DelayMount extends PureComponent {
static propTypes = {
render: PropTypes.bool.isRequired,
children: PropTypes.any,
transitionEnterDelay: PropTypes.number.isRequired,
transitionLeaveTimeout: PropTypes.number.isRequired
}
@renarsvilnis
renarsvilnis / imageHelpers.js
Last active May 31, 2017 09:05
Helper functions for calculating fit, fill dimensions of an image, rect,.. in JavaScript
export function calcFitDimensions (target, boundries, upscale = false) {
if (!target.width || !target.height || !boundries.width || !boundries.height) {
return calcCenterPosition(target, boundries);
}
let imgRatio = target.width / target.height;
let newWidth;
let newHeight;
// if image is horizontal
/**
* ES6 way of removing nth array element in an immutable way
* @param [Array] arr
* @param [number] i
* @return [Array]
*/
function removeNthEl (arr, i) {
return [
...arr.slice(0, i),
...arr.slice(i + 1)
@renarsvilnis
renarsvilnis / gist:6e8c455663f3601f9f1c
Last active August 29, 2015 14:19
Tips for web app security
@renarsvilnis
renarsvilnis / server-setup-guide-warp.md
Last active December 11, 2022 21:48
Guide for configuring server for apache, php, ssh etc..

DEV SERVER SETUP


A reference for setting up Linux/Ubuntu server for LAMP, Node.js laboratory.

May be helpful for others, hence this git. If it contains errors, please push them.

This assumes

@renarsvilnis
renarsvilnis / php-tricks-n-tips.md
Last active August 29, 2015 14:17
Some tips or useful info about PHP that i found interesting or useful at the moment of writing.