Skip to content

Instantly share code, notes, and snippets.

@bhavyaw
bhavyaw / get_title_and_url.applescript
Created September 14, 2016 06:20 — forked from vitorgalvao/Get Title and URL.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# 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
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)
@bhavyaw
bhavyaw / centos6-atrpms-ffmpeg.sh
Created July 12, 2016 11:16 — forked from ilyaevseev/centos6-atrpms-ffmpeg.sh
Install fresh FFMpeg to CentOS 6 from the dead ATrpms repo.
#!/bin/bash
rpm --import https://raw.githubusercontent.com/example42/puppet-yum/master/files/CentOS.6/rpm-gpg/RPM-GPG-KEY.atrpms
rpm -Uvh https://www.mirrorservice.org/sites/dl.atrpms.net/el6.7-x86_64/atrpms/stable/atrpms-repo-6-7.el6.x86_64.rpm
sed -i 's,http://dl,https://www.mirrorservice.org/sites/dl,' /etc/yum.repos.d/atrpms*.repo
yum install ffmpeg
@bhavyaw
bhavyaw / parseTime.js
Created June 4, 2016 14:41
Parses Time String to JavaScript Date Object
/**
* Parsing Time in String to a Date Obj
* @param timeString - time in String
* --> Acceptable Times -
* 1,01,10,011,101,110,0111,1011,
* With AM/PM - 1p,01p,10p
*
* @returns tempDateObj {Date} - Date Object that represents time String
*/
function parseTimeString(timeString) {
1.) We can't access private members in methods that are added to the object at a later point.
2.) Writing Unit Tests for Private Functions
@bhavyaw
bhavyaw / debouncer.js
Created June 4, 2016 14:41
Javascript Debounce Utilities
// Implementation
// run key up event handler as debounced key down handlers
var
_debounceTimeout; // key debouncer required params
// Usage
debounceStart(function(){
// Function which is to be debounced
});
@bhavyaw
bhavyaw / umd-script-boilerplate.js
Created March 21, 2016 12:19 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {