Skip to content

Instantly share code, notes, and snippets.


Dave Davis davedavis

View GitHub Profile
View gist:d6af70b8dfeb7044825e99652f9a9a5f
from bs4 import BeautifulSoup
from urllib import request
x = 4
testlist = {1,2,3,4}
for num in testlist:
View gist:93b60e1252fc9dcb59352d662e5f80a2
View gist:afd22fe0eb0e3035cececfcc4a6a77af
sudo apt-get install libgnutls30:i386 libldap-2.4-2:i386 libgpg-error0:i386 libxml2:i386 libasound2-plugins:i386 libsdl2-2.0-0:i386 libfreetype6:i386 libdbus-1-3:i386 libsqlite3-0:i386
sudo dpkg --add-architecture i386
sudo apt-add-repository 'deb bionic main'
sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport
davedavis / gist:f62e3273f6876847cdb97b8e9b097339
Created Jan 27, 2020
Install Google Ads Editor on Ubuntu (2020)
View gist:f62e3273f6876847cdb97b8e9b097339
// Download from :
// Set up wine 5:
// Then in the same directory as the downloaded file, run wine as:
wine msiexec /i ./google_adwords_editor.msi
davedavis / gist:ac48bbbef51c462256fac70d3ad2d03c
Created Feb 14, 2020
Selector for select HTML element (for using with onClick as opposed to onChange)
View gist:ac48bbbef51c462256fac70d3ad2d03c
/* assuming we have the following HTML
<select id='s'>
<option selected>Second</option>
var select = document.getElementById('s');
View gist:86187e6965ef7cae42a3791ee399ecc1
ssh -R 12345:localhost:22 dave@externalserverIPaddress
That’ll set up a reverse SSH tunnel from your external server (listening on port 12345) to your internal server
Then SSH to your external server when you’re at home and then connect through the tunnel by running :
ssh dave@ -p 12345
davedavis / gist:44ef4a35cd190dc28dd03f034b8bc15a
Created Jun 23, 2020
Last 28 Days in Python - For Reporting
View gist:44ef4a35cd190dc28dd03f034b8bc15a
# Define the report date range: last 28 days including today"-", "") + timedelta(days= - 28)
davedavis / gist:9f7eafd1e215c0aee84d10d611e9f434
Created Jun 23, 2020
Fiscal Year and Quarter To Date in Python
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(
>> print(quarter)
>> print(type(quarter))
>> print(quarter.start)
davedavis / gist:8a7933353a94d97f2929fab285845cbf
Created Jun 24, 2020
How to get Google Ads API ENUM Text Value From The The Returned Integer Index - Google Ads API ENUM Mapping
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')
# => 2
# => 'SEARCH'
This was found by looking at docstrings, e.g.
davedavis / gist:0a8b62f6c15c8040faa6c833c82f4cee
Created Sep 10, 2020
How to Sign Github Commits From PyCharm
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
You can’t perform that action at this time.