Skip to content

Instantly share code, notes, and snippets.

@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 / 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
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
git clone https://github.com/salrashid123/grpc_curl
cd grpc_curl/src/
virtualenv env --no-site-packages
source env/bin/activate
pip install grpcio-tools hexdump
python -m grpc_tools.protoc -I . --python_out=. --grpc_python_out=. echo.proto
def w(filename):
req = echo_pb2.EchoRequest(firstname='john', lastname='doe')
msg = binascii.b2a_hex(req.SerializeToString())
frame = '00' + hex(len(msg)/2).lstrip("0x").zfill(8) + msg
print 'Raw Encode: ' + frame
f = open(filename, "wb+")
f.write(binascii.a2b_hex(frame))
f.close()
$ xxd frame.bin
00000000: 0a04 6a6f 686e 1203 646f 65 ..john..doe
$ xxd -p frame.bin
0a046a6f686e1203646f65
$ echo `xxd -p frame.bin` | xxd -r -p | protoc --decode_raw
1: "john"
2: "doe"
>>> msg = '0a046a6f686e1203646f65'
>>> print '00' + hex(len(msg)/2).lstrip("0x").zfill(8) + msg
000000000b0a046a6f686e1203646f65
echo -n '000000000b0a046a6f686e1203646f65' | xxd -r -p - frame.bin