Skip to content

Instantly share code, notes, and snippets.

View ruffle1986's full-sized avatar
🖖
live long

Tamas Fodor ruffle1986

🖖
live long
View GitHub Profile
@ruffle1986
ruffle1986 / player.less
Created July 9, 2014 13:29
A CSS technique to keep 16:9 aspect ratio in the case of responsive video elements. ".video" refers to the video html element.
.player-wrapper {
position: relative;
width: 100%;
height: 0;
padding-bottom: percentage(9 / 16);
border: 1px solid black;
.video {
position: absolute;

There are three types of layout in our application:

  • The landing page
  • The home screen (with or without back button)
  • And the default layout for static sites and login/signup etc.

Every layout has its own @mediaquery modifications

(Note: I prefer the "Mobile First" principle)

@ruffle1986
ruffle1986 / gist:a913215dbb712276d051
Created January 26, 2015 12:27
Different header text font sizes
.header-text-logo {
font-size: 18px;
&[title="Enjora"] {
font-size: 20px;
}
}
player
.use(seekBar)
.use(volumeControl);
if (user.hasAccess) {
player
.use(watchLaterControl)
.use(fullscreenControl)
.use(inVideoSearch);
} else {
@ruffle1986
ruffle1986 / gist:e5e33b6f530c8c77d8ce
Created March 10, 2015 13:55
Cartesian Product of Arrays
function cartesianProductOf() {
return _.reduce(arguments, function(a, b) {
return _.flatten(_.map(a, function(x) {
return _.map(b, function(y) {
return x.concat([y]);
});
}), true);
}, [ [] ]);
};
@ruffle1986
ruffle1986 / gist:859df28e200098df574f
Last active August 29, 2015 14:24
Lazy Image Loader
(function (factory) {
'use strict';
if (typeof exports !== 'undefined') {
module.exports = factory();
} else {
window.LazyImageLoader = factory();
}
}(function () {
@ruffle1986
ruffle1986 / gist:e96776a2b4d4d387900d
Last active August 29, 2015 14:24
2x image url replacer
'image.jpg'.replace(/\.([a-z|0-9]+)$/, '@2x.$1') // image@2x.jpg
'image.jpg'.replace(/(.+)(\.\w+)$/, "$1@2x$2") // image@2x.jpg
@ruffle1986
ruffle1986 / redux-middleware-crash-reporter.js
Created September 14, 2015 09:22
Redux Crash Reporter Middleware
export default store => next => action {
try {
return next(action)
} catch (err) {
// log error and handle the exception
}
}
@ruffle1986
ruffle1986 / redux-reducer-immutability-test.js
Created September 24, 2015 15:50
redux reducer immutability test
import test from 'ava';
import * as actionTypes from './your-action-types';
import reducer from './your-reducer';
import deepEqual from 'deep-equal';
test('reducer:immutability test', t => {
const dummy = {};
for (const action in actionTypes) {
if (actionTypes.hasOwnProperty(action)) {
const result = reducer(dummy, {type: actionTypes[action]});
@ruffle1986
ruffle1986 / szorgalmi.js
Created November 15, 2015 17:16
balint szorgalmi
var competitors = require('./competitors.json');
if (!Array.isArray(competitors)) {
console.log('Hiba: az átadott elem típusának tömbnek kell lennie.');
}
competitors
.sort(function (a, b) {
return b.points - a.points;
})