Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrey G. plandem

View GitHub Profile
@plandem
plandem / register-sw.js
Created Aug 3, 2020 — 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 && registration.active) {
// 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. ¯\_(ツ)_/¯
View xcode-build-bump.sh
# xcode-build-bump.sh
# @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)
View afred_workflows.txt
https://github.com/podgorniy/alfred-translate
View ios7statusbar.md

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):
View osx_install.sh
#!/bin/bash
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
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
@plandem
plandem / d3js layout scaling
Last active Jul 27, 2016
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 = d3.select('div')
.append("svg:svg")
.attr("width", width)
.attr("height", height)
You can’t perform that action at this time.