Skip to content

Instantly share code, notes, and snippets.

View davidpaulsson's full-sized avatar

David Paulsson davidpaulsson

View GitHub Profile
@davidpaulsson
davidpaulsson / index.js
Created November 6, 2021 13:14 — forked from jadenlemmon/index.js
Example A/B Test Gatsby v4 SSR Cookies
import { sample } from 'lodash';
import React from 'react';
import cookie from 'cookie';
import Layout from '../components/layout';
import HomeV1 from '../components/scenes/home/v1';
import HomeV2 from '../components/scenes/home/v2';
const EXPERIMENT_OPTIONS = {
v1: HomeV1,
v2: HomeV2,
/*--------------------------------------------------------------
Flexbox grid
--------------------------------------------------------------*/
// Wrapper
.grid {
display: flex;
}
// Alignment per row
Verifying that +davidpaulsson is my openname (Bitcoin username). https://onename.com/davidpaulsson

Keybase proof

I hereby claim:

  • I am davidpaulsson on github.
  • I am davidpaulsson (https://keybase.io/davidpaulsson) on keybase.
  • I have a public key whose fingerprint is 7F6E 0C62 26CB 9F49 B685 3C63 2246 ACB6 100C 1333

To claim this, I am signing this object:

@davidpaulsson
davidpaulsson / padding-bottom-hack.css
Last active August 29, 2015 13:58
CSS needed for padding-bottom hack
/*
* CSS needed for https://gist.github.com/davidpaulsson/10101172
*/
img {
max-width: 100%;
height: auto;
}
/* Non-fluid images if you specify `width` and/or `height` attributes. */
@davidpaulsson
davidpaulsson / rwd-lazy-loading.js
Last active February 3, 2016 03:24
Lazy loading with padding-bottom hack for responsive images
/**
* Place this inline at the bottom of the html document, right before
* closing `</body>`. It's important to have this inline as we want to
* display images asap.
*
* Markup example for the actual images. It also calculates the image
* container using the [padding-top hack](https://gist.github.com/davidpaulsson/10101985),
* please do this calculation on the back end, before drawing the DOM.
* Current example can load three images sizes, customize to fit your needs. It
* also adds the calculated image URL as an data-original tag on the img element it creates,
@davidpaulsson
davidpaulsson / render_time.rb
Last active August 29, 2015 13:57 — forked from blakesmith/render_time.rb
Displays the time a Jekyll page was generated in format "Month DD, YYYY"
# An example Jekyll Liquid tag. Utilizes the new plugin system.
#
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there.
# 2. In anyone of your pages, you can use the 'render_time' liquid tag like so:
# {% render_time Page generated at: %}
module Jekyll
class RenderTimeTag < Liquid::Tag
def initialize(tag_name, text, tokens)
@davidpaulsson
davidpaulsson / wp-get_id_by_slug
Created February 26, 2014 06:20
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@davidpaulsson
davidpaulsson / bash_profile open in chrome
Created February 19, 2014 07:17
.bash_profile candy
# open a file in chrome
# usage: $ chrome index.html
function chrome() {
open $@ --args --allow-file-access-from-files
}
@davidpaulsson
davidpaulsson / jQuery.maxHeight
Created June 27, 2013 11:47
Equalize heights of div elements
var maxHeight = 0;
$('div').each(function(){
if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$('div').height(maxHeight);