Skip to content

Instantly share code, notes, and snippets.

View jasonpolites's full-sized avatar

Jason jasonpolites

View GitHub Profile
MODEL_NAME=census
MODEL_VERSION=v1
@jasonpolites
jasonpolites / upload.js
Last active December 5, 2017 18:05
Uploading files using GCF. The following example uses the busboy npm module, but you can use any valid multipart parser module that takes a Buffer as input.
/**
* Copyright 2017, Google, Inc.
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@jasonpolites
jasonpolites / hello.txt
Last active November 15, 2017 18:07
File Uploads in GCF
Hello World!
@jasonpolites
jasonpolites / url-signer.js
Last active November 13, 2017 21:45
Demo of manually signing a GCS url
/**
* Copyright 2017, Google, Inc.
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@jasonpolites
jasonpolites / generateJwt.js
Last active November 3, 2017 20:27
[Very] Rough example of how to sign a JWT in GCF
const rp = require('request-promise');
exports.generateJwt = (req, res) => {
let serviceNamePromise = getServiceAccountName();
let serviceTokenPromise = getServiceAccountToken();
Promise.all([
serviceNamePromise,
serviceTokenPromise]).then((values) => {
@jasonpolites
jasonpolites / blobSigner.js
Last active November 9, 2017 23:47
[Very] rough example of using the signBlob API in GCP
const rp = require('request-promise');
exports.blobSigner = (req, res) => {
let serviceNamePromise = getServiceAccountName();
let serviceTokenPromise = getServiceAccountToken();
Promise.all([
serviceNamePromise,
serviceTokenPromise]).then((values)=>{
try {
var process = new ffmpeg(pathToVideo);
process.then(function (video) {
// Video metadata
console.log(video.metadata);
// FFmpeg configuration
console.log(video.info_configuration);
callback(null, video.metadata);
@jasonpolites
jasonpolites / action_bar_reload_with_create.java
Created January 23, 2012 21:34
Reload Action Bar With Create Entity
// Create a class to handle the callback from the action bar
public class MyActionBarListener implements ActionBarListener {
private ActionBarView actionBarView;
@Override
public void onCreate(ActionBarView actionBar) {
// Store a reference to the actionBar view
this.actionBarView = actionBar;
}
@jasonpolites
jasonpolites / action_bar_init.java
Created November 18, 2011 10:57
Socialize Action Bar Init (Simple)
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.socialize.ui.SocializeUI;
public class SampleActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// These can be specified in a config file
@jasonpolites
jasonpolites / gist:1343724
Created November 6, 2011 22:43
AppTribes Manifest
<manifest...>
<application...>
<!-- Activities Required by AppTribes -->
<activity android:name="com.apptribes.ApptribesActivity"/>
</application>
<!-- Permissions Required by AppTribes -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>