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 collatz(max) { | |
| let tree = [1]; | |
| function calculate(parent, num) { | |
| if (tree.length >= max) { | |
| return; | |
| } | |
| const leftChild = 2*parent+1; |
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 collatz(maxLevels){ | |
| let levels = [[1]] | |
| while (levels.length < maxLevels) { | |
| let level = []; | |
| levels[levels.length-1].forEach(function(num){ | |
| const mod6 = ((num-4)%6); | |
| const odd = (num-1)/3; | |
| if (!mod6 && odd != 1) { | |
| level.push(odd) | |
| } |
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
| import os | |
| import json | |
| import urllib2 | |
| import re | |
| class Scanner: | |
| result = [] | |
| driver = None | |
| movies_directory = 'Movies' |
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
| def get_movie_info(self, movie): | |
| match = re.search('\d{4}', movie['file']) | |
| year = match.group(0).strip().replace(' ', '%20') if match else '' | |
| title = movie['file'].replace(year, '').strip().replace(' ', '%20') if match else movie['file'].strip().replace(' ', '%20') | |
| request = urllib2.urlopen(self.omdb+'?t='+title+'&y='+year+'&r=json').read() | |
| movie_object = json.loads(request, object_hook=self.ascii_encode_dict) | |
| movie_object['File'] = movie['file'] | |
| movie_object['filePath'] = movie['path'] |
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
| class Scanner: | |
| movies = [] | |
| movies_directory = '' | |
| def __init__(self): | |
| self.get_file_names() | |
| def get_file_names(self): | |
| for dir_name, sub_dir_list, file_list in os.walk(self.movies_directory): |
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
| from selenium import webdriver | |
| from twilio.rest import TwilioRestClient | |
| class Dividends: | |
| driver = None | |
| capital_url = 'https://www.capitaloneinvesting.com/' | |
| username = 'capital one investing username' | |
| password = 'capital one investing password' |
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
| def process_transactions(self): | |
| print "Processing transactions ...." | |
| transaction_table = self.driver.find_element_by_css_selector('#TransactionHistoryList tbody') | |
| rows = transaction_table.find_elements_by_css_selector('tr') | |
| for row in rows: | |
| cells = row.find_elements_by_css_selector('td') | |
| print cells[0].text + ' ' + cells[2].text + ' ' + cells[6].text | |
| print "Done." |
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
| def load_transactions(self): | |
| print "Loading transactions ..." | |
| transactions_link = self.driver.find_element_by_css_selector('#ctl00_ctl00_header_ctl19') | |
| transactions_link.click() | |
| self.screenshot('transactions.png') | |
| print "Done." |
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
| def login(self): | |
| print 'Login ...' | |
| self.driver.get(self.capital_url) # capital_url - Capital One Investing home page url | |
| username_field = self.driver.find_element_by_css_selector('input#widget_signInUsername') | |
| username_field.clear() # clear() is required for their form or send_key() below will fail | |
| username_field.send_keys(self.username) | |
| password_field = self.driver.find_element_by_css_selector('input#widget_signInPassword') | |
| password_field.clear() | |
| password_field.send_keys(self.password) | |
| submit = self.driver.find_element_by_css_selector('#widget > div.SignInButtonWrapper > div.SignIn > a') |
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.storage.local.get("medium_views", function(items) { | |
| var viewsStorage = items["medium_views"] || {}; | |
| var viewsDOM = getViewsFromDOM(); | |
| for (var title in viewsDOM) { | |
| if (viewsStorage[title] && viewsStorage[title] != viewsDOM[title]) { | |
| updateDOM(title, viewsStorage[title]); | |
| } | |
| } |