This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formatMinutesToDuration(durationInMinutes){ | |
let formattedDuration = ``; | |
if(durationInMinutes){ | |
let derivedHours = round( (durationInMinutes / 60 ),3); | |
let hours = Math.trunc(derivedHours); | |
let derivedMinutes = Math.abs(derivedHours - Math.floor(derivedHours)); | |
let minutes = Math.trunc(derivedMinutes * 60); | |
let hoursFormatted = hours ? ( (hours < 10) ? `0${hours}` : hours ) : "00"; | |
let minuteFormatted = minutes ? ( (minutes < 10) ? `0${minutes}` : minutes ) : "00"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
var myAwesomePromise = new Promise((resolve,reject) => { | |
setTimeout(() => { | |
resolve("Timeout - 2000 promise is resolved"); | |
},2000); | |
}); | |
var resolvedPromise = Promise.resolve("This is a resolved promise"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var $ = require('nodobjc'); | |
// Load the AppKit framework. | |
$.framework('AppKit'); | |
// Create delegate that gets notified | |
var Delegate = $.NSObject.extend('Delegate'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set windowTitle to "" | |
set currentTabTitle to "" | |
set appID to "" | |
set appName to "" | |
set comments to "" | |
set visWins to totalVisibleWindows() | |
tell application "System Events" | |
set frontApp to first application process whose frontmost is true | |
set appName to name of frontApp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set windowTitle to "" | |
set currentTabTitle to "" | |
set appID to "" | |
set appName to "" | |
set comments to "" | |
set wins to "" | |
set anyFinderWindowVisible to false | |
set anyVisibleWindow to anyVisibleWindow() | |
tell application "System Events" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set windowTitle to "" | |
set currentTabTitle to "" | |
set appID to "" | |
set appName to "" | |
set comments to "" | |
set wins to "" | |
set anyFinderWindowVisible to false | |
tell application "System Events" | |
set frontApp to first application process whose frontmost is true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Keep in mind that when asking for a `return` after another, only the first one will be output. | |
# This example is meant as a simple starting point, to show how to get the information in the simplest available way. | |
# Google Chrome | |
tell application "Google Chrome" to return URL of active tab of front window | |
tell application "Google Chrome" to return title of active tab of front window | |
# Google Chrome Canary | |
tell application "Google Chrome Canary" to return URL of active tab of front window | |
tell application "Google Chrome Canary" to return title of active tab of front window | |
# Chromium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require("child_process").exec; | |
var multiline = require("multiline"); | |
var Q = require('q'); | |
module.exports = { | |
start : runScript, | |
stop : stopScript | |
} | |
//Applescript to get active window title. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//********************************************************************** | |
// function waitfor - Wait until a condition is met | |
// | |
// Needed parameters: | |
// test: function that returns a value | |
// expectedValue: the value of the test function we are waiting for | |
// msec: delay between the calls to test | |
// callback: function to execute when the condition is met | |
// Parameters for debugging: | |
// count: used to count the loops |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myWorker = new Worker("DetectWakeup.js"); | |
myWorker.onmessage = function (ev) { | |
if (ev && ev.data === 'wakeup') { | |
// wakeup here | |
} | |
} | |
// DetectWakeup.js (put in a separate file) | |
var lastTime = (new Date()).getTime(); | |
var checkInterval = 10000; |
NewerOlder