Skip to content

Instantly share code, notes, and snippets.

@jeffgodwyll
jeffgodwyll / index.html
Created September 29, 2017 18:58
GDG Meetup API Sample Usage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Meetup endpoints</title>
<ul></ul>
</head>
<body>
var SPREADSHEET_ID = 'SHEET_ID_HERE';
var SHEET_NAME = 'SHEET_NAME_HERE';
function doGet() {
var range = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName(SHEET_NAME).getDataRange();
var json = JSON.stringify(range.getValues());
return ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.JAVASCRIPT);
}
@jeffgodwyll
jeffgodwyll / pre-commit.md
Last active April 16, 2017 18:33
Check for style guide issues before commit

Install flake8

$ pip install flake8`

Edit pre-commit file

$ vim .git/hooks/pre-commit`

to show and enforce styleguide conventions before commit, add the following:

[{"plans": [{"specs": [{"disk": 3072, "dollars_per_hr": 0.01, "description": "1 vCPU (shared physical core) and 0.6 GB RAM", "dollars_per_mo": 6, "transfer": "unlimited?", "ram": 614, "id": "1000", "cpu": 1}], "name": "f1-micro", "id": "f1-micro"}, {"specs": [{"disk": 3072, "dollars_per_hr": 0.035, "description": "1 vCPU (shared physical core) and 1.7 GB RAM", "dollars_per_mo": 23, "transfer": "unlimited?", "ram": 1740, "id": "2000", "cpu": 1}], "name": "g1-small", "id": "g1-small"}, {"specs": [{"disk": 65536, "dollars_per_hr": 0.792, "description": "16 vCPUs, 14.4 GB RAM", "dollars_per_mo": 532, "transfer": "unlimited?", "ram": 14746, "id": "4016", "cpu": 16}], "name": "n1-highcpu-16", "id": "n1-highcpu-16"}, {"specs": [{"disk": 65536, "dollars_per_hr": 0.099, "description": "2 vCPUs, 1.8 GB RAM", "dollars_per_mo": 66, "transfer": "unlimited?", "ram": 1843, "id": "4002", "cpu": 2}], "name": "n1-highcpu-2", "id": "n1-highcpu-2"}, {"specs": [{"disk": 65536, "dollars_per_hr": 1.584, "description": "32 vCPUs, 28
@jeffgodwyll
jeffgodwyll / refresh_token.py
Created June 19, 2016 01:29
To generate refresh token to use with Google API's for user data
#!/usr/bin/python
#
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Prevent nemo from creating a desktop window that shows icons
gsettings set org.nemo.desktop show-desktop-icons false
# Snippet 1
###########
# Copy the build folder(containing the html files) to a folder in flask's static
# directory and serve this way:
@app.route('/<dir>/<filename>', defaults={'static': True})
def build_dir(dir='',filename='index.html'):
path = join(dir,filename)
return app.send_static_file(path)
@jeffgodwyll
jeffgodwyll / recursive_x_mod
Created March 2, 2015 23:42
When I move my android sdk folder onto an NTFS disk, I tend to loose the executable bit. This is to remedy the situation a whole lot better.
# Run in project root
# Recursively add executable bit to all files without a dot filename
find -type f -not -name "*.*" -exec chmod +x \{\} \;
# Recursively add exec bit to all files with .so in filename
find -type f -name "*.so*" -exec chmod +x \{\} \;
# Recursively add exec bit to all files with .so in filename
find -type f -name "*.jar*" -exec chmod +x \{\} \;
#!/usr/bin/python
'''
Convert Blogger xml-exported file to markdown
Primarily from https://gist.github.com/larsks/4022537 with some modifications
'''
import os
import sys
import argparse
import iso8601
import re
@jeffgodwyll
jeffgodwyll / urlexists.py
Last active August 29, 2015 14:10
Test for valid url before scraping
import requests
def url_exists(url):
response = requests.get(url)
return response.status_code == requests.codes.ok
url_exists('http://google.com') #True: exists
url_exists('http://jeffgodwyll.com/ht.m') #False: doesn't exist