Skip to content

Instantly share code, notes, and snippets.

Stef Lewandowski stefl

Block or report user

Report or block stefl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stefl
stefl / fix.js
Created May 19, 2018
Fix for Next.js / React SSR meta tags have URL-encoded content
View fix.js
// React SSR renders out <meta tags with URL-encoded values.
// That's bad if you need query parameters in your URLs.
// Before: <meta property="og:image"
// content="https://makelight-prismic-images.imgix.net/7f97d951970bbb15a8b3744e4c69499ffe969d66_img_1010.jpg?w=1200&amp;h=630&amp;fit=crop&amp;crop=entropy&amp;auto=format&amp;ixlib=js-1.1.1" class="next-head"/>
// (Notice the &amp;s in the URL)
//
// After: <meta property="og:image"
// content="https://makelight-prismic-images.imgix.net/cfb3a074bfcab5793eded64ef077dd6260d6d89b_img_0578.jpg?w=1200&h=630&fit=crop&crop=entropy&auto=format&ixlib=js-1.1.1" class="next-head"/>
// (Notice &amp; is now correctly &
//
View Prismic Memcache cache
# encoding: utf-8
module Prismic
class Memcache
def initialize(max_size=100)
end
def set(key, value, expired_in = nil)
View designer.html
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
@stefl
stefl / Why hack.md
Last active Dec 18, 2015
Why Hack?
View Why hack.md

Why Hack?

At Makeshift we’re rapidly hacking on digital products that give a leg up to the little guy. We're a team of hackers, designers and product people who get out of bed each morning excited (okay, most mornings) to make new apps that bring our ideas to life.

We're kicking off our new blog series, "Why Hack?" featuring you. We want to know what gets you out of bed in the morning, or more specifically Why and How You Hack!

Over the next month, we will be posting these interviews on our blog + sending them out to our mailing list.

Thanks in advance for your thoughts!

@stefl
stefl / avatar-caching
Created May 10, 2013
Use memcache on repetitive avatar requests in Rails
View avatar-caching
def avatar(options = {})
key = "avatar-#{nickname}-#{options.map {|k,v| "#{k}:#{v}" }.join("-")}"
cached_avatar = Rails.cache.fetch(key)
return cached_avatar if cached_avatar
options.reverse_merge!({size: 48})
unless model.nil?
avatar = h.link_to(h.person_path(model)) do
h.image_tag(avatar_address,
class: 'avatar__img',
data: { src: avatar_address },
@stefl
stefl / gist:5322519
Last active Dec 15, 2015
The names of the data sets that #nhtg13 have provided. All 9374 of them
View gist:5322519
["1-1-5m-scale-geology-through-climate-change-poster-map-covering-uk-mainland-northern-ireland-an",
"1-1056-scale-town-plans-1848-1939",
"1-50-000-scale-gazetteer",
"1-500-scale-town-plans-1848-1939",
"1-50000-scale-gazetteer",
"1-528-scale-town-plans-1848-1939",
"10k-sheet-data-files",
"13-butadiene-running-annual-mean-at-automatic-sites-comparison-with-health-objective-for-2003-u-2010",
"15th-percentile-house-prices-land-registry",
"1987-ongoing-met-office-marine-automatic-weather-station-maws-meteorological-observations",
@stefl
stefl / gist:5143269
Created Mar 12, 2013
Weird "localhost" oddness
View gist:5143269
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 lvh.me
@stefl
stefl / foundation_paginate.rb
Last active Dec 13, 2015 — forked from mariszin/foundation_paginate.rb
Zurb Foundation now uses 'current' instead of 'active' for the active page.
View foundation_paginate.rb
# Based on https://gist.github.com/1182136 and https://gist.github.com/1586384
# Make the will_paginate generate markup for Zurb Foundation
# Put this in config/initializers/foundation_paginate.rb
module WillPaginate
module ViewHelpers
class LinkRenderer < LinkRendererBase
protected
def html_container(html)
tag(:ul, html, container_attributes)
@stefl
stefl / gist:4540506
Created Jan 15, 2013
Contenteditable hover and focus states
View gist:4540506
[contenteditable]:hover:after {
content: ' click to edit';
font-style: italic;
font-size: 12px;
color: #ccc;
}
[contenteditable]:hover, [contenteditable]:focus {
background: #FFFFD3;
}
@stefl
stefl / gist:2385517
Created Apr 14, 2012
Rails button_to helper using a button tag rather than an input tag
View gist:2385517
def button_to_with_button_element(name, options = {}, html_options = {})
fragment = ::Nokogiri::HTML.fragment(button_to(name, options, html_options))
fragment.css("input[type=submit]").each do |input|
input.replace ::Nokogiri::HTML.fragment("<button class='#{input.attribute("class")} type='submit'>#{input.attribute("value")}</button>")
end
raw fragment.to_html
end
You can’t perform that action at this time.