Skip to content

Instantly share code, notes, and snippets.

@salrashid123
salrashid123 / gist:de891486b5b595f561cbcdcdcb2c7b4a
Created April 4, 2017 04:50
List users with Google Directory API
#!/usr/bin/python
from apiclient.discovery import build
import httplib2
from oauth2client.service_account import ServiceAccountCredentials
from oauth2client.client import GoogleCredentials
import logging
import json
import sys
@salrashid123
salrashid123 / datalab_logging.py
Last active June 10, 2018 21:15
Google Cloud Logging events as Dataframes
# virtualenv env
# source env/bin/activate
# pip install jupyter matplotlib pandas google-cloud-logging
#%%
import collections
@salrashid123
salrashid123 / TestApp.java
Last active April 23, 2017 18:38
GCS SignedURL in java with metadata headers
package com.test;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.util.Collection;
import java.util.Iterator;
import java.io.FileInputStream;
import com.google.auth.oauth2.GoogleCredentials;
@salrashid123
salrashid123 / cloudlogging.py
Last active July 7, 2018 16:54
Cloud Logging google-python
import os
import pprint
from google.cloud import logging
from google.cloud.logging import ASCENDING
from google.cloud.logging import DESCENDING
pp = pprint.PrettyPrinter(indent=1)
FILTER = 'resource.type="gae_app" AND logName="projects/mineral-minutia-820/logs/appengine.googleapis.com%2Frequest_log" AND protoPayload.resource="/"'
@salrashid123
salrashid123 / Dockerfile
Created May 29, 2017 00:51
dotnet_sln_files
# build stage
FROM microsoft/dotnet:2.0.0-preview1-sdk-jessie AS build-env
ADD . /app
WORKDIR /app/
RUN dotnet restore
RUN dotnet publish -c Release
# final stage
FROM microsoft/dotnet:2.0.0-preview1-runtime-jessie
COPY --from=build-env /app /app/
WORKDIR /app/
@salrashid123
salrashid123 / directory.png
Last active July 29, 2017 03:52
.NET GCF
directory.png
private static void Execute(IApplicationBuilder app)
{
app.Run(async context =>
{
_logger.LogInformation("HTTP handler called..");
await context.Response.WriteAsync("hello from .NET");
});
}
sudo su -
wget https://download.docker.com/linux/debian/dists/jessie/pool/edge/amd64/docker-ce_17.05.0~ce-0~debian-jessie_amd64.deb
dpkg -i docker-ce_17.05.0~ce-0~debian-jessie_amd64.deb
(press Y, when prompted)
service docker restart
exit
@salrashid123
salrashid123 / server.go
Last active August 3, 2021 09:34
Google cloud logging consolidated logging in golang
package main
//https://github.com/GoogleCloudPlatform/google-cloud-go/issues/720#issuecomment-320798620
import (
"fmt"
"log"
"net/http"
"time"
apt-get update -y && apt-get install -y unzip curl python openssl python-setuptools python-pip python-dev build-essential nghttp2 libnghttp2-dev libssl-dev
curl -OL https://curl.haxx.se/download/curl-7.54.0.tar.bz2 && \
tar -xvjf curl-7.54.0.tar.bz2 && \
cd curl-7.54.0 && \
./configure --with-nghttp2 --with-ssl && \
make && \
make install && \
ldconfig