Skip to content

Instantly share code, notes, and snippets.

View richieforeman's full-sized avatar
😻

Richie Foreman richieforeman

😻
View GitHub Profile
@richieforeman
richieforeman / sample.pac
Last active April 2, 2024 19:41
Sample PAC File for Google Apps Deployments
function FindProxyForURL(url, host) {
// Plain hostnames. ( e.g. http://server )
if (isPlainHostName(host)) {
return "DIRECT";
}
// Private address classes.
if (isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
isInNet(dnsResolve(host), "172.16.0.0", "255.240.0.0") ||
@richieforeman
richieforeman / makeauthority.sh
Created July 23, 2012 21:38
Issue Your Own Self-Signed S/MIME Certs with OpenSSL
# Run this once
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@richieforeman
richieforeman / exp.java
Last active April 20, 2020 18:47
exp.java
//// First, Implement an interface to intercept the HTTP Request before it goes out.
package com.google.java_scratch;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.http.HttpBackOffIOExceptionHandler;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler.BackOffRequired;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
@richieforeman
richieforeman / tracing_token_example.java
Last active January 8, 2016 16:33
Google API Tracing Token - Java
//// First, Implement an interface to intercept the HTTP Request before it goes out.
import java.io.IOException;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
public class TracingTokenInitializer implements GoogleClientRequestInitializer {
@Override
public void initialize(AbstractGoogleClientRequest<?> req) throws IOException {
System.out.println("Attaching tracing token...");
req.put("trace", "token:<<TOKEN GOES HERE>>");
@richieforeman
richieforeman / tracing_token_sample.php
Last active January 8, 2016 16:32
Google API Tracing Token - PHP
$service = new Google_Service_Directory($googleClient);
// A tracing token can be utilizing with the PHP 1.0 library by passing an associative array to
// the '$optParams' value of the method call. The order of this parameter varies for each method call,
// but is typically immediately after the required arguments.
//
// The tracing token parameter will need to be added to EACH AND EVERY call where a tracing token is required.
$makeAdmin = new Google_Service_Directory_UserMakeAdmin();
$makeAdmin->setStatus(true);
$service->users->makeAdmin('marty.mcfly@timecircuit.org', $makeAdmin, array(
@richieforeman
richieforeman / tracing_token_example.py
Last active January 8, 2016 16:31
Google API Tracing Token - Python
service = build(serviceName="admin",
version="directory_v1",
http=httplib2.Http())
# A tracing token can be attached by utilizing the 'trace' kwarg on a method call.
# Switching the request to utilize all 'kwargs' is recommended.
#
# Importantly, when a request (such as the one below) includes a body parameter,
# the tracing token should NOT be included in the body.
#
@richieforeman
richieforeman / list_compare.py
Created October 31, 2012 16:57
Compare two simple files and return the differences
import sys
import os
def read_file(f, split="\n"):
return open(f).read().split(split)
list1 = read_file(sys.argv[1])
list2 = read_file(sys.argv[2])
@richieforeman
richieforeman / reseller_list_customers.py
Last active August 29, 2015 14:22
Reseller List Customers
import csv
import httplib2
from argparse import ArgumentParser
from oauth2client.client import SignedJwtAssertionCredentials
from apiclient.discovery import build
SCOPES = [
'https://www.googleapis.com/auth/apps.order'
]
<!DOCTYPE html>
<html>
<head>
<title>JS Client Test Bench</title>
</head>
<body>
<script type="text/javascript">
var SETTINGS = {
CLIENT_ID: '801883730557-sm0htkeqruc79vm569f20gk8ponn62sv.apps.googleusercontent.com',
API_KEY: 'AIzaSyDobgkbnTo75Vb7XmgNBemxvbT_YKFTAPE',
import os
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
http = httplib2.Http()
SCOPES = [
'https://www.googleapis.com/auth/calendar'
]