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
w= 1000;h=500 | |
x=0;xy=0;y=w;yx=h | |
sf= abs((w-h)/2) | |
if w>h:x=x+sf | |
if w>h:y=w-sf | |
if w<h:xy=sf | |
if w <h:yx=h-sf | |
print (sf) |
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
#!/usr/bin/env python3 | |
import scrapy | |
class MySpider(scrapy.Spider): | |
name = 'myspider' | |
start_urls = ['http://www.usfigureskating.org/leaderboard/results/2018/25073/SEGM001.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
#!/usr/bin/env python3 | |
import scrapy | |
class MySpider(scrapy.Spider): | |
name = 'myspider' | |
start_urls = ['http://www.usfigureskating.org/leaderboard/results/2018/25073/SEGM001.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
x = input("What programming language do you know ?") | |
keywords = ["Python", "JavaScript", "Ruby"] | |
if any(keyword in x for keyword in keywords): | |
print("I know that language also !") |
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
# Combines all *.txt files in a directory into one | |
# NOTICE: it is saved as a .text extension. | |
# That is so it will not be read as a result file of a new search | |
import time, glob | |
clean=open("test.text");clean.close() | |
#outfilename = 'all_' + str((int(time.time()))) + ".txt" | |
outfilename = "test.text" | |
filenames = glob.glob('*.txt') | |
with open(outfilename, 'wb') as outfile: |
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
# USAGE EXAMPLE: | |
# From gogle link - https://drive.google.com/file/d/1J18blSZ5ic_SoEOc7pGBz_Sr4RIZJUuK/view?usp=sharing | |
# 1J18blSZ5ic_SoEOc7pGBz_Sr4RIZJUuK is the file ID | |
# python GDownload.py 1J18blSZ5ic_SoEOc7pGBz_Sr4RIZJUuK google.db | |
import requests | |
import sys | |
def download_file_from_google_drive(id, destination): | |
URL = "https://docs.google.com/uc?export=download" | |
session = requests.Session() |
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 sys | |
""" | |
Displays a range of lines in a file | |
USAGE: | |
""" | |
filename = sys.argv[1] | |
start = int(sys.argv[2]) | |
end = int(sys.argv[3]) | |
f = open(filename, "r") | |
lines = f.readlines() |
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
Simple use: | |
#2 argvs filename and search term/word | |
#USAGE below to search the file ElementTree.py for the word 'parse ': | |
#python SearchFile.py ElementTree.py parse | |
import sys | |
filename = sys.argv[1] | |
search = sys.argv[2] | |
#f = open("ElementTree.py") | |
f = open(filename) | |
lines = f.readlines() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder