Seconds to elapsed time in readable English in:
- Javascript
- PHP
- BASH
| /** | |
| * Execute the loopBody function once for each item in the items array, | |
| * waiting for the done function (which is passed into the loopBody function) | |
| * to be called before proceeding to the next item in the array. | |
| * @param {Array} items - The array of items to iterate through | |
| * @param {Function} loopBody - A function to execute on each item in the array. | |
| * This function is passed 3 arguments - | |
| * 1. The item in the current iteration, | |
| * 2. The index of the item in the array, | |
| * 3. A function to be called when the iteration may continue. |
| #!/usr/bin/env bash | |
| # uninstall | |
| # | |
| # Helper script to deep uninstall stuff from Mac | |
| # | |
| # Usage example 1 | |
| # uninstall firefox | |
| # Will find all files installed by firefox and ask for confirmation before removing them | |
| # |
| // Sets the value of a query string parameter if it exists else adds it | |
| // keeping hash value and all other values intact | |
| function setQSParam(url, key, value=''){ | |
| var qs = url.substr(~url.indexOf("?")?url.indexOf("?")+1:url.length); | |
| var hash = qs.substr(~url.indexOf('#')?qs.lastIndexOf('#'):qs.length); | |
| url = url.substr(0, url.length-hash.length); | |
| qs = qs.substr(0, qs.length-hash.length); | |
| var sep = !qs&&url.substr(-1)!=='?'?'?':!!qs&&url.substr(-1)!=='&'?'&':''; | |
| var added=0,nqs=[],k,v,parts; |
| function getBrowserName(){ | |
| var nAgt = navigator.userAgent; | |
| var browserName = navigator.appName; | |
| var nameOffset, verOffset; | |
| if ((verOffset = nAgt.indexOf("Opera")) != - 1) browserName = "Opera"; | |
| else if ((verOffset = nAgt.indexOf("MSIE")) != - 1) browserName = "Microsoft Internet Explorer"; | |
| else if ((verOffset = nAgt.indexOf("Chrome")) != - 1) browserName = "Google Chrome"; | |
| else if ((verOffset = nAgt.indexOf("Safari")) != - 1) browserName = "Safari"; | |
| else if ((verOffset = nAgt.indexOf("Firefox")) != - 1) browserName = "Mozilla Firefox"; | |
| else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) { |
| #!/bin/bash | |
| # Convert all splash screen images in a cordova project to a | |
| # simple gradient with a logo overlay scaled to fit inside 80% of the image | |
| project=/path/to/cordova/project | |
| logo=/path/to/overlay/img.png | |
| gradient1="rgba(0,99,81,1)" | |
| gradient2="rgba(55,171,106,1)" |
The steps I took to dual boot Arch Linux alongside the preinstalled Windows 10 that came with my new Lenovo Ideapad. I used Ubuntu exclusively for the last 6 years so I'm Window's illiterate. I don't know a whole lot about the inner workings of Linux either.
Prepare the preinstalled Windows to share the system.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>TODO supply a title</title> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| </head> | |
| <body> | |
| <canvas id="canvas" style="height:90vh;"></canvas> | |
| <script> |
| // requires protodate.js | |
| // https://github.com/Pamblam/protodate | |
| function calculateJulianDay(date){ | |
| var y = parseInt(date.format("Y")); | |
| var m = parseInt(date.format("n")); | |
| if(m === 1 || m === 2){ | |
| y -= 1; | |
| m += 12; | |
| } |
| #!/bin/bash | |
| # Download old version of SDK to rollback to | |
| # Google Developer Console => | |
| # App releases => | |
| # Production (Manage Production) => | |
| # Release history => | |
| # Select the version that you want => | |
| # Click on Download button. |