Skip to content

Instantly share code, notes, and snippets.

View johanneslumpe's full-sized avatar

Johannes Lumpe johanneslumpe

View GitHub Profile
@johanneslumpe
johanneslumpe / gist:10446664
Created April 11, 2014 07:26
Triggering pseudo-element changes on hover in IE
.container {
background: #f00;
width:50px;
height: 50px;
}
.container:before {
content: " ";
display: block;
background:#fff;
@johanneslumpe
johanneslumpe / gist:11137765
Created April 21, 2014 09:43
Fullsize background videos in webkit browsers gist 1
video {
min-width: 100%;
min-height: 100%;
position: fixed;
left: 0;
top: 0;
z-index: -1;
}
@johanneslumpe
johanneslumpe / gist:11137971
Last active August 29, 2015 14:00
Fullsize background videos in webkit browsers gist 2
.my-fixed-item {
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
}
@johanneslumpe
johanneslumpe / gist:11138248
Last active August 29, 2015 14:00
Fullsize background videos in webkit browsers gist 3
html,body {
/* this fix background images with fixed positioning */
overflow-x:hidden
}
@johanneslumpe
johanneslumpe / gist:11138298
Created April 21, 2014 10:08
Fullsize background videos in webkit browsers gist 4
window.addEventListener('scroll', function (e) {
// unfortunately this will never fire
console.log('we are scrolling!');
}, false);
document.querySelector('body').addEventListener('scroll', function (e) {
// this one will fire though
console.log('yay!');
}, false);
@johanneslumpe
johanneslumpe / gist:11138662
Created April 21, 2014 10:23
Fullsize background videos in webkit browsers gist 5
var body = document.querySelector('body');
body.scrollTop = 100;
console.log(body.scrollTop); // 0 :(
@johanneslumpe
johanneslumpe / gist:11139066
Last active August 29, 2015 14:00
Fullsize background videos in webkit browsers gist 6
// quick and dirty check for webkit, which has a bug that it does not compute the
// proper scrollTop, when overflowX is set on the body. We can use this to decide
// when we have to disable fixed-attachment backgrounds, because they lead to a rendering
// issue in webkit. This test is just a naive implementation and probably could be improved
// but works fine for now.
var overflowScrollTopBuggy = function overflowScrollTopBuggy () {
if (testFixedBackgrounds.buggy) {
return testFixedBackgrounds.buggy;
}
var body = document.querySelector('body');
// this works fine
render: function() {
var content = [];
if (this.state.showResults && this.props.results.length) {
content.push(<ResultList results={this.props.results} onResultSelectAction={this.onResultSelectAction} />);
}
return (
<div className="searchbox-wrapper">
var Backbone = require('backbone');
var _ = require('lodash');
// extend `Backbone.AssociatedModel` with a create method, which will be
// used to create new models for us, instead of using `new`
// shamelessly inspired by Supermodel
var Cached = Backbone.AssociatedModel.extend({
_cached: false,
_ref: 0,
ref: function () {
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
) t;