Skip to content

Instantly share code, notes, and snippets.

View davedavis's full-sized avatar
:octocat:

Dave Davis davedavis

:octocat:
View GitHub Profile
@davedavis
davedavis / gist:8a7933353a94d97f2929fab285845cbf
Created June 24, 2020 23:16
How to get Google Ads API ENUM Text Value From The The Returned Integer Index - Google Ads API ENUM Mapping
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.
@davedavis
davedavis / gist:9f7eafd1e215c0aee84d10d611e9f434
Created June 23, 2020 21:06
Fiscal Year and Quarter To Date in Python
>> 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)
@davedavis
davedavis / gist:44ef4a35cd190dc28dd03f034b8bc15a
Created June 23, 2020 21:05
Last 28 Days in Python - For Reporting
# 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("-","")
@davedavis
davedavis / gist:86187e6965ef7cae42a3791ee399ecc1
Created May 21, 2020 21:03
Create a reverse SSH tunnel
FROM INTERNAL:
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@127.0.0.1 -p 12345
@davedavis
davedavis / gist:ac48bbbef51c462256fac70d3ad2d03c
Created February 14, 2020 21:27
Selector for select HTML element (for using with onClick as opposed to onChange)
/* assuming we have the following HTML
<select id='s'>
<option>First</option>
<option selected>Second</option>
<option>Third</option>
</select>
*/
var select = document.getElementById('s');
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 https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport
python3
ranger
neofetch
net-tools
postgres
apache2
flask
htop
@davedavis
davedavis / gist:d6af70b8dfeb7044825e99652f9a9a5f
Created January 29, 2019 23:43
Basic Beautiful Soup Request
from bs4 import BeautifulSoup
from urllib import request
x = 4
print(x)
testlist = {1,2,3,4}
for num in testlist:
print(num)