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
/* | |
The actual javascript code starts from document.forms[0].username.value.... however to run it in the URL bar (address bar) of a browser you have to put the entire Javascript Code in this format javascript:{<YOUR JAVASCRIPT CODE>} | |
I have tested it in Chrome, Firefox, Internet Explorer and Safari and it works perfectly fine. If you notice any different behaviour with any other browsers, please test and contribute. | |
Simply replace <YOUR USER NAME> with your actual username and <YOUR PASSWORD> with your actual login password and run this in browser address bar (no need to input actual URL in the JavaScript code) | |
------------------------------------------------------------------------------------------------------------ | |
CAUTION: PLEASE ENSURE YOU KEEP YOUR PASSWORD SECURE AS YOU ACTUALLY GIVE YOUR PASSWORD IN TEXT FORMAT INSIDE THIS JAVASCRIPT CODE, SO IF ANYONE GETS ACCESS TO THIS CODE THEY WILL GET ACCESS TO YOUR 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
//Get a random value from a list of words | |
list1 = ["Hi", "How", "are", "you"]; | |
list1[Math.floor(Math.random() * list1.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
//Replacing http with https by manipulating DOM element as shown below | |
document.location.href = document.location.href.replace("http","https"); | |
/* ** .replace function will replace the text passed as first argument with the text passed as second argument | |
** document.location.href returns current URL including the fragments / query parameters in the URL | |
*/ | |
//OR | |
document.location.protocol = 'https:' | |
// Changes URL protocol to https from whatever it is currently. |
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
""" | |
## This function returns title of the Youtube Video whose video_id is passed to the function as a parameter | |
## You must have Google Data Python Client Library installed and path setup for this to work. | |
## More information on that can be found here: | |
## https://developers.google.com/gdata/articles/python_client_lib#library | |
""" | |
import gdata.youtube |
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
""" | |
Timing code execution time. | |
From book: Problem Solving with Algorithms and Data Structures: http://interactivepython.org/runestone/static/pythonds/AlgorithmAnalysis/Lists.html | |
This code times the execution time of each function. | |
test1() uses concatenation method to create a list of 1000 numbers from 0 to 999 | |
test2() uses append method to create a list of 1000 numbers from 0 to 999 | |
test3() uses list comprehension to create a list of 1000 numbers from 0 to 999 | |
test4() uses range function inside list function to create a list of 1000 numbers from 0 to 999 | |
For timing the test case execution, we are here using Python's timeit module. More about it: https://docs.python.org/2/library/timeit.html | |
""" |
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
""" | |
Timing code execution time. | |
From book: Problem Solving with Algorithms and Data Structures: http://interactivepython.org/runestone/static/pythonds/AlgorithmAnalysis/Lists.html | |
This code times the execution of pop operation for popping first element in a list and popping last element in a list. | |
For timing the test case execution, we are here using Python's timeit module. More about it: https://docs.python.org/2/library/timeit.html | |
""" | |
import timeit | |
popzero = timeit.Timer("x.pop(0)", "from __main__ import x") |
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 sqlite3 as lite | |
import sys | |
con = None | |
try: | |
con = lite.connect(u"C:\\Python27\\test.db") | |
cur = con.cursor() |
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 sqlite3 as lite | |
import os | |
import sys | |
# def con_to_file(filename): | |
# #Ensure correct filename / filepath is given as argument to the function | |
# con = lite.connect(filename) | |
# cur = con.cursor() |
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 pywinauto.application import Application | |
app = Application.start('notepad') | |
app.Notepad.MenuSelect('Help->AboutNotepad') | |
app.AboutNotepad.OK.Click() #May have to do it twice to bring notepad application in focus first and then click on OK in the second time. | |
# app.AboutNotepad.OK.Click() | |
app.Notepad.MenuSelect('Format->Font') | |
app.Font.FontComboBox.Select('Arial') | |
app.Font.FontStyleCombo.Select('Bold Italic') | |
app.Font.OK.Click() |
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 | |
# Change to directory where the folders are located that you want to work with! | |
os.chdir('path/for/directory') | |
for item in os.listdir(os.getcwd()): | |
# os.path.isfile returns true if the specified path is a file | |
# Hence not os.path.isfile returns true if the specified path is NOT A FILE (i.e. a directory) | |
if not os.path.isfile(os.path.join(os.getcwd(),item)): | |
if '.' in item: |