Skip to content

Instantly share code, notes, and snippets.

View jrjames83's full-sized avatar

Jeff James jrjames83

View GitHub Profile
@jrjames83
jrjames83 / adwordsbid.js
Created March 16, 2016 16:00
adwords bid2
function main() {
// make sure single digit dd's don't appear without a leading zero
Number.prototype.padZero= function(len){
var s= String(this), c= '0';
len= len || 2;
while(s.length < len) s= c + s;
return s;
}
function myFunction() {
//https://developers.google.com/apps-script/reference/mail/mail-app#sendemailmessage
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var charts = sheet.getCharts()[0];
var chart_image = charts.getAs("image/png").setName("hourly_chart")
var d = new Date();
var currentTime = d.toLocaleTimeString();
function myFunction() {
//https://developers.google.com/apps-script/reference/mail/mail-app#sendemailmessage
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var charts = sheet.getCharts()[0];
var chart_image = charts.getAs("image/png").setName("hourly_chart")
var d = new Date();
var currentTime = d.toLocaleTimeString();
@jrjames83
jrjames83 / connect.py
Created March 29, 2016 15:02
remote ssh tunnel python
from sshtunnel import SSHTunnelForwarder
import psycopg2
#http://stackoverflow.com/questions/22046708/
#https://github.com/pahaz/sshtunnel
#at least wrap in a try except block
server = SSHTunnelForwarder(
('remote.server.ip', remote.port),
ssh_username="jeff",
@jrjames83
jrjames83 / freq.py
Created April 3, 2016 20:40
getting term frequencies from csv file using python
import csv
from stop_words import get_stop_words
from collections import Counter
#Get the file into a list
with open('taw_quer.csv', 'rb') as f:
reader = csv.reader(f)
data = list(reader)
"""
@jrjames83
jrjames83 / scrape.py
Last active May 4, 2016 03:44
scrape some obama speeches
from bs4 import BeautifulSoup
import requests
import urllib
#if that shit doesn't load, do from terminal
#python -m pip install module name or pip install module
url = "http://www.americanrhetoric.com/barackobamaspeeches.htm"
response = requests.get(url)
@jrjames83
jrjames83 / google_vision_ex.py
Created May 6, 2016 00:41
example of google vision api for label detection
import argparse
import base64
import httplib2
import os
from apiclient.discovery import build
from oauth2client.client import GoogleCredentials
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'secret.json'
@jrjames83
jrjames83 / euler13.go
Created June 7, 2016 03:03
Project Eueler 13 in Go
package main
import (
"fmt"
//"strconv"
"strings"
"math/big"
)
@jrjames83
jrjames83 / euler4.py
Last active June 10, 2016 16:20
Largest palindrome product (python euler4)
#https://projecteuler.net/problem=4
#https://projecteuler.net/problem=4
def isPal(string):
if len(string) <= 1:
return True
if list(string)[0] != list(string)[-1]:
return False
@jrjames83
jrjames83 / get_data.py
Created August 12, 2016 18:18
python script to get ga data
import argparse
import csv
import os.path
import datetime
import time
from datetime import date, timedelta as td
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials