Skip to content

Instantly share code, notes, and snippets.

View BlogBlocks's full-sized avatar

Jack Northrup BlogBlocks

View GitHub Profile
@BlogBlocks
BlogBlocks / !ocate center
Last active April 24, 2018 21:44
largest center square of image
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)
@BlogBlocks
BlogBlocks / ScrapySider py
Created December 17, 2017 00:05
spider from Stackoverflow
#!/usr/bin/env python3
import scrapy
class MySpider(scrapy.Spider):
name = 'myspider'
start_urls = ['http://www.usfigureskating.org/leaderboard/results/2018/25073/SEGM001.html']
@BlogBlocks
BlogBlocks / ScrapySider py
Created December 17, 2017 00:05
spider from Stackoverflow
#!/usr/bin/env python3
import scrapy
class MySpider(scrapy.Spider):
name = 'myspider'
start_urls = ['http://www.usfigureskating.org/leaderboard/results/2018/25073/SEGM001.html']
@BlogBlocks
BlogBlocks / mult.py
Last active December 17, 2017 00:06
multiple keywords
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 !")
@BlogBlocks
BlogBlocks / jointxt.py
Last active December 19, 2017 00:22
Combines all *.txt files in a directory into one
# 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:
@BlogBlocks
BlogBlocks / GDownload.py
Last active December 19, 2017 00:22
Google Drive Downloader
# 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()
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()
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()
@BlogBlocks
BlogBlocks / trasa.geojson
Created December 5, 2017 06:14
geojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BlogBlocks
BlogBlocks / FFMPEG.ipynb
Last active December 19, 2017 00:24
ffmpeg jupyter notebook. everything works fine video maker.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.