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
## create a temp dir to manage the download | |
download_dir = os.path.join("/tmp/", str(uuid.uuid4())) | |
os.makedirs(download_dir, exist_ok=True) | |
# Create directories if they don't exist | |
## update selenium to download to your new directory | |
driver.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command') | |
params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': download_dir}} |
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 logging | |
from settings import LOGGING_LEVEL | |
LOGGING_FORMAT = '%(asctime)s - AutoUpload - \ | |
%(levelname)s - %(message)s' | |
logging.basicConfig(level=LOGGING_LEVEL, format=LOGGING_FORMAT) |
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
from apscheduler.schedulers.blocking import BlockingScheduler | |
import sys, traceback | |
sched = BlockingScheduler() | |
@sched.scheduled_job('interval', | |
id='check_carts', | |
minutes=1, |
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
temp_folder = "/tmp/" + str(uuid.uuid4()) + "/" | |
zip_file = 'images_{0}.zip'.format(uuid.uuid4()) | |
os.mkdir(temp_folder) | |
for image in images: | |
# generate some dir | |
# figure out how to use unique name (from s3) | |
image_name = image.converted.name.replace("converted/", "").replace("tmp/","") | |
image = image.converted.open() | |
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 time | |
start = time.time() | |
print("hello") | |
end = time.time() | |
print(end - start) |
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
<!-- this is in your customers/login.liquid template file --> | |
{% form 'customer_login', novalidate: 'novalidate', return_to: '/pages/test-page' %} |
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
// put this in your theme's header.liquid template file | |
{% if customer %} | |
//requires JS Cookies library if you want to store their email. *optional* | |
Cookies.set('email','{{ customer.email }}',{expires:1}); | |
{% else %} | |
if (window.location.href.indexOf('account') == -1){ |
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
#from Bio import Medline | |
import sys | |
!{sys.executable} -m pip install biopython |
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
"""" README | |
This is a simpler workaround to the heroku django database package. If you want to run a local sqlite database | |
and be able to easily switch to a remote heroku database (through only one ENV with the DATABASE_URL) this will work. | |
Installation: | |
The below code goes into your django settings file (in place of the existing database configuration) | |
Set the ENV DATABASE_URL by copying it over from your Heroku Instance. | |
Set the ENV LOCAL=0 to connect to Heroku |
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
from django.core.files import File | |
import requests | |
## to download from a URL and store in a django FileField() | |
s3_url = "yours3_url_here" | |
with open('temp_file.txt', 'wb') as f: | |
f.write(requests.get(s3_url).content) |
NewerOlder