Skip to content

Instantly share code, notes, and snippets.

View josephdburdick's full-sized avatar
😇
Mentally present

Joe josephdburdick

😇
Mentally present
View GitHub Profile
@josephdburdick
josephdburdick / service-worker.js
Last active August 29, 2015 14:27 — forked from deanhume/service-worker.js
Register Service Worker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
registration.pushManager.subscribe().then(function(subscription){
isPushEnabled = true;
console.log("subscription.subscriptionId: ", subscription.subscriptionId);
console.log("subscription.endpoint: ", subscription.endpoint);
// TODO: Send the subscription subscription.endpoint
// non-modular
jQuery.fn.limit = function(count){
return $(this).filter(function(index){ return index < count; });
};
// non-modular usage
$('sel').limit(3);
// modular
var $ = require('jquery');

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

.row
overflow: hidden
margin-top: 1.5em
&:first-child
margin-top: 0
.column
float: left
margin-left: 5%
&:first-child
margin-left: 0
&.full
width: 100%
.column
float: left
margin-left: 5%
&:first-child
margin-left: 0
.container
margin: 0 auto
max-width: 960px
width: 90%
*, *:before, *:after
-moz-box-sizing: border-box
-webkit-box-sizing: border-box
box-sizing: border-box
@media xs
.column.full,
.column.two-thirds,
.column.half,
.column.one-third,
.column.one-fourth
float: none;
margin: 0;
width: 100%;
class BottlesOfBeer
def count_off
puts "How many bottles of beer have you got?"
numbers = gets.chomp.to_i
word_bottles = "bottles"
numbers.downto(1) do |number|
puts "\n#{number} #{word_bottles} of beer on the wall"
puts "#{number} #{word_bottles} of beer!"
puts "You take one down and pass it around,"