Skip to content

Instantly share code, notes, and snippets.

plandem / register-sw.js
Created August 3, 2020 14:10 — forked from jeffposnick/register-sw.js
A modern-ish SW registration script, detecting various state changes.
View register-sw.js
if ('serviceWorker' in navigator) {
window.addEventListener('load', async function() {
const registration = await navigator.serviceWorker.register('/service-worker.js');
if (registration.waiting && {
// The page has been loaded when there's already a waiting and active SW.
// This would happen if skipWaiting isn't being called, and there are
// still old tabs open.
console.log('Please close all tabs to get updates.');
} else {
// updatefound is also fired for the very first install. ¯\_(ツ)_/¯
plandem / d3js layout scaling
Last active July 27, 2016 09:21
Correct zoom of layout
View d3js layout scaling
In some cases you want to handle zooming and rescale your layout.
But at all examples you can see something like this:
var width = 640;
var height = 480;
var outer ='div')
.attr("width", width)
.attr("height", height)
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
plandem / afred_workflows.txt
Created August 23, 2014 19:46
alfred workflows
View afred_workflows.txt

UIStatusBarStyle in iOS 7

  • The status bar in iOS 7 is transparent, the view behind it shows through.

  • The style of the status bar refers to the appearances of its content. In iOS 7, the status bar content is either dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent). Both UIStatusBarStyleBlackTranslucent and UIStatusBarStyleBlackOpaque are deprecated in iOS 7.0. Use UIStatusBarStyleLightContent instead.

How to change UIStatusBarStyle

  • If below the status bar is a navigation bar, the status bar style will be adjusted to match the navigation bar style (UINavigationBar.barStyle):
plandem /
Last active August 29, 2015 13:59
OSX setup
ruby -e "$(curl -fsSL"
brew update
brew upgrade
brew tap homebrew/versions
brew tap phinze/homebrew-cask
brew install midnight-commander wget git git-flow curl redis node phantomjs ssh-copy-id