Skip to content

Instantly share code, notes, and snippets.


Renārs Vilnis renarsvilnis

View GitHub Profile

Keybase proof

I hereby claim:

  • I am renarsvilnis on github.
  • I am renarsvilnis ( on keybase.
  • I have a public key ASCqW6nmRyxAuawicthyZFzwvp-FVybO76yYRTzLcdfr7go

To claim this, I am signing this object:

View pino-http.js
// ...
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] ||
if (!req.res) { req.res = res }
res.on('finish', onResFinished)
renarsvilnis / DelayMount.js
Last active Apr 4, 2017
<DelayMount/> component
View DelayMount.js
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 / imageHelpers.js
Last active May 31, 2017
Helper functions for calculating fit, fill dimensions of an image, rect,.. in JavaScript
View imageHelpers.js
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
View remove-nth-es6.js
* 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 / gist:6e8c455663f3601f9f1c
Last active Aug 29, 2015
Tips for web app security
View gist:6e8c455663f3601f9f1c
renarsvilnis /
Last active May 26, 2017
Guide for configuring server for apache, php, ssh etc..


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 /
Last active Aug 29, 2015
Some tips or useful info about PHP that i found interesting or useful at the moment of writing.
View read-length-of-mp3.php
ini_set("max_execution_time", "30000");
// how much detail we want. Larger number means less detail
// (basically, how many bytes/frames to skip processing)
// the lower the number means longer processing time
define("DETAIL", 5);
define("DEFAULT_WIDTH", 500);