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
//background.js | |
chrome.runtime.onInstalled.addListener( | |
function () { | |
chrome.alarms.create("gcgmalarm",{when: Date.now() + 10*1000,periodInMinutes: 2}); | |
}); | |
function alarmcount(callback) { | |
var count; | |
chrome.alarms.getAll(function(alarms) { callback(alarms.length) }); | |
} |
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 match = 'https://calendar.google.com/calendar/render' | |
//http://stackoverflow.com/questions/18162644/adding-a-listener-that-fires-whenever-the-user-changes-tab | |
//When Google Calendar browser tab is active again!!! | |
chrome.tabs.onActivated.addListener(function(activeInfo) { | |
chrome.tabs.get(activeInfo.tabId, function (tab) { | |
//chrome.tabs.sendMessage(activeInfo.tabId, {action: "tabactive", consolelog: tab.url.substring(0, match.length)},function(response) {}); | |
if (tab.url.substring(0, match.length) === match) { | |
chrome.tabs.sendMessage(activeInfo.tabId, {action: "start"}, function(response) {}); | |
} |
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 timeoutId = 0; | |
window.addEventListener('resize', function() { | |
if (DEBUG === true) { console.log("browser resizing ......");} | |
if (timeoutId) { | |
clearTimeout(timeoutId); | |
} | |
timeoutId = setTimeout(function() { | |
Start(); | |
timeoutId = 0; | |
}, 100); |
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
//All content loaded in the Google Calendar browser tab! | |
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { | |
if (changeInfo.status == 'complete') { | |
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){ | |
chrome.tabs.sendMessage(tabs[0].id, {action: "start"}, function(response) {}); | |
}); | |
}; | |
}); |
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
chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) { | |
//tab loaded | |
if (msg.action == 'start') { | |
if (DEBUG === true) { console.log("tab loaded");} | |
Start(); | |
} | |
}); | |
function Start(){ | |
var today = document.getElementsByClassName('lv-location'); |
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
{ | |
"manifest_version": 2, | |
"name": "MapIt for Google Calendar", | |
"version": "0.1", | |
"content_scripts": [ | |
{ | |
"matches": ["*://calendar.google.com/calendar/render*"], | |
"js": ["content.js"] | |
} | |
], |
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
# Find different combinations | |
def combinations(n): | |
yield "" | |
for i, d in enumerate(n): | |
for combination in combinations(n[i+1:]): | |
yield d + combination | |
print([x for x in combinations("abc")]) | |
#output | |
['', 'a', 'ab', 'abc', 'ac', 'b', 'bc', 'c'] |
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
#Reference: http://pythoncentral.io/python-generators-and-yield-keyword/ | |
#Find the first n number of the Fibonacci series | |
def fibonacci(n): | |
curr = 1 | |
prev = 0 | |
counter = 0 | |
while counter < n: | |
#print("Generator invoked ..") | |
yield curr |
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
#Reference: http://pythoncentral.io/python-generators-and-yield-keyword/ | |
#Read small chunks from big buffer | |
def buffered_read(input): | |
#Read a big chunk of data | |
buffer = input | |
#Return small chunks on demand | |
for small_chunk in buffer: | |
print("Generator invoked ..") | |
yield small_chunk |
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
#Reference: http://pythoncentral.io/python-generators-and-yield-keyword/ | |
from time import sleep | |
def hold_client(name): | |
yield 'Hello, %s! You will be connected soon' % name | |
yield 'Dear %s, could you please wait a bit.' % name | |
yield 'Sorry %s, we will play a nice music for you!' % name | |
yield '%s, your call is extremely important to us!' % name | |
yield '%s, please call back latter' % name | |
# putting it all together |
NewerOlder