This file contains 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 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
#!/bin/bash | |
# corrects the error | |
# Error: dconf-CRITICAL **: unable to create file '~/.cache/dconf/user': Permission denied. dconf will not work properly. | |
# Run fix-permissions.sh as sudo | |
# $1 is a variable to insert your name as owner | |
# Use Example: | |
# chmod +x fix-permissions.sh | |
# sudo ./fix-permissions.sh yourusername | |
chown $1 ~/.cache/dconf | |
chown $1 ~/.cache/conf |
This file contains 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
#!/bin/bash | |
# ** (mousepad:540): WARNING **: Couldn't connect to accessibility bus: | |
# Failed to connect to socket /tmp/dbus-tGXmtmmBTs: Connection refused | |
# If you do not use alley - | |
# Add the following to ~/.bashrc: | |
echo "export NO_AT_BRIDGE=1" ~/.bashrc | |
source ~/.bashrc | |
This file contains 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 | |
import time | |
import sqlite3 | |
Dbase = 'test0.db' | |
conn = sqlite3.connect(Dbase) | |
c = conn.cursor() | |
c.execute(''' | |
CREATE VIRTUAL TABLE IF NOT EXISTS merge | |
USING FTS3(file, keyword); | |
''') |
This file contains 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 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 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 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 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 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() |