View gist:407abbd3800c6d31771b8ac93f9bc2fe
OK, after a lot of heartache, I've solve this. As usual, the solution was painfully simple. | |
Certifi uses it's own bundled certificate bundle, so you can use the one from here: https://curl.haxx.se/ca/cacert.pem | |
Basically, download it (or use your own from the certifi dist directory) | |
Then, set the env variable (in /etc/envirnoment if you're on Ubuntu like me) for $SSL_CERT_FILE to the one you downloaded: | |
export SSL_CERT_FILE=/home/yourname/cacert.pem | |
Worked immediately from main system CLI. I had to uninstall PyCharm and reinstall it for it to pick up the env variable and start working in virtualenvs again. | |
View gist:3d49c0966a1314966b928427991122e4
Comment out or set the IP of the bind address manually in /etc/mysql/my.cnf | |
Restart the service. | |
Create the user AGAIN (Because MySQL treats users on localhost and users on remote as different) | |
CREATE USER 'username'@'%' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'; |
View gist:3d43e9746310706e170b039c6ce2f9c9
When you build from Ubuntu, apt-get update increases the size by about 600GB. | |
Instead, don't install the recommended updates, just what you need: | |
In your docker file: | |
RUN apt-get update && apt-get install --no-install-recommends --yes python3 | |
Ref: https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends |
View gist:e84c96e94ea01172b81df4d8425ca0a5
from datetime import datetime, time | |
def is_time_between(begin_time, end_time): | |
# If check time is not given, default to current UTC time | |
check_time = datetime.utcnow().time() | |
if begin_time < end_time: | |
return begin_time <= check_time <= end_time | |
else: # crosses midnight | |
return check_time >= begin_time or check_time <= end_time |
View gist:cb1f75e09b81cc07f09e02c8167ac582
source myprojectenv/bin/activate | |
git pull origin master | |
python manage.py makemigrations | |
python manage.py migrate | |
python manage.py collectstatic | |
sudo service gunicorn restart | |
sudo service nginx restart |
View gist:0a8b62f6c15c8040faa6c833c82f4cee
Set up your GPG key and add it to github by: | |
gpg --full-generate-key | |
gpg --default-new-key-algo rsa4096 --gen-key | |
Then, get your GPG ID: | |
gpg --list-secret-keys --keyid-format LONG | |
The ID is the bit after the "sec rsa4096/": | |
gpg --armor --export 3AA5C34371567BD2 |
View Install-Google-Ads-Editor-Ubuntu
Download the Editor exe here: http://dl.google.com/adwords_editor/GoogleAdsEditorSetup.exe | |
Install Wine: | |
sudo dpkg --add-architecture i386 | |
wget -O - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - | |
sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main' | |
sudo apt update; sudo apt install --install-recommends winehq-stable winetricks | |
Open Wineconfig and change the OS to Windows 10: | |
winecfg |
View gist:8a7933353a94d97f2929fab285845cbf
The Enum's come with some methods to translate between index and string | |
# client_service is the GoogleAdsClient object. | |
channel_types = client_service.get_type('AdvertisingChannelTypeEnum') | |
channel_types.AdvertisingChannelType.Value('SEARCH') | |
# => 2 | |
channel_types.AdvertisingChannelType.Name(2) | |
# => 'SEARCH' | |
This was found by looking at docstrings, e.g. |
View gist:9f7eafd1e215c0aee84d10d611e9f434
>> import fiscalyear | |
>> fiscalyear.setup_fiscal_calendar(start_month=4) | |
>> year = fiscalyear.FiscalYear(2021) | |
>> quarter = fiscalyear.FiscalQuarter.current() | |
>> print(year.start.year) | |
>> print(year.start.month) | |
>> print(year.start.day) | |
>> print(quarter) | |
>> print(type(quarter)) | |
>> print(quarter.start) |
View gist:44ef4a35cd190dc28dd03f034b8bc15a
# Define the report date range: last 28 days including today | |
start=datetime.today().date().isoformat().replace("-", "") | |
end=datetime.now() + timedelta(days= - 28) | |
end= end.date().isoformat().replace("-","") |
NewerOlder