Skip to content

Instantly share code, notes, and snippets.

View renarsvilnis's full-sized avatar
🌊

Renārs Vilnis renarsvilnis

🌊
View GitHub Profile
@renarsvilnis
renarsvilnis / _png-svg-fallback.scss
Last active August 29, 2015 14:01
Sass png-svg fallback
// sass svg fallback to png (or your desired extension)
// similar to other fallbacks but this supports < 4 firefox
@mixin png-svg-fallback($url, $extension: '.png') {
background-image: url($url + $extension);
background-image: -webkit-linear-gradient(transparent, transparent), url($url + ".svg");
background-image: linear-gradient(transparent, transparent), url($url + ".svg");
}
@renarsvilnis
renarsvilnis / _remove-focus-color.scss
Last active August 29, 2015 14:01
Sass mixing for removing focus color
// mixin for easy focus color removement
@mixin remove-focus-color {
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */
}
@renarsvilnis
renarsvilnis / css-tricks-n-tips.md
Last active August 29, 2015 14:06
Usefull tricks and tips which i gain from working on projects

TIPS

  • If parent has overflow hidden and child has backface-visibility: hidden; then fonts on chrome <= 37 render blurry due to the are converted to and image upscaled.

FONTS

@renarsvilnis
renarsvilnis / read-length-of-mp3.php
Last active August 29, 2015 14:11
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);
@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.
@renarsvilnis
renarsvilnis / gist:6e8c455663f3601f9f1c
Last active August 29, 2015 14:19
Tips for web app security
/**
* 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 / 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