Skip to content

Instantly share code, notes, and snippets.

Compute compute = ComputeOptions.defaultInstance().service();
String instanceName = "bla";
String projectId = "blu";
String zone = "ble"; // e.g. europe-west1-d
InstanceId instanceId = InstanceId.of(projectId, zone, instanceName);
Instance instance = compute.getInstance(instanceId);
try {
List<String> data = new LinkedList<String>();
// or if you know the amount of data upfront:
List<String> data = new ArrayList<String>(3);
data.add("hello");
data.add("hello");
data.add("bye");
System.out.println(data.size()); // 3
// in order to lookup data you always have to iterate the whole list until you find the value you're looking for
@TomTasche
TomTasche / Gruntfile.js
Created December 27, 2015 22:35
dispatcher for multi-module appengine setups
// ...
var proxySnippet = require("grunt-connect-proxy/lib/utils").proxyRequest;
gruntConfig.connect = {
server: {
options: {
port: 9000,
hostname: "0.0.0.0",
keepalive: true,
middleware: function(connect, options) {
@TomTasche
TomTasche / extract-certificate.sh
Created September 1, 2014 18:00
commands i used to extract the ssl-certificate from a running system for usage with heroku
keytool -list -keystore keystore.jks
keytool -export -alias 1 -keystore store.jks -file store2.crt
openssl x509 -in store2.crt -out store2-pem.crt -outform pem -inform der
keytool -v -importkeystore -srckeystore store.jks -srcalias 1 -destkeystore store2.p12 -deststoretype PKCS12
openssl pkcs12 -in store2.p12 -out store2.pem
openssl rsa -in store2.key -inform DER -out store2-nopw.key
# https://devcenter.heroku.com/articles/ssl-endpoint#update-certificate
//
// IDViewController.m
// MyFirstIndoorsApp
//
// Copyright (c) 2013 indoo.rs GmbH. All rights reserved.
//
#import "IDViewController.h"
#import <CoreLocation/CoreLocation.h>
@TomTasche
TomTasche / ndk-gdb-remote
Last active May 8, 2018 10:07
ndk-gdb of NDK r9d modified to *always* debug the ":remote"-process of your app
#!/bin/sh
#
# Copyright (C) 2010 The Android Open Source Project
#
# 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
#
#replace count=1024 with the number of MB (!) you want to grow the image file
dd if=/dev/zero bs=1024k count=1024 >> my_loop_image_file
e2fsck -f my_loop_image_file
resize2fs my_loop_image_file
@TomTasche
TomTasche / debug_log.cpp
Last active December 31, 2015 22:29
console output in C++
std::cout << "debug message: " << array.size() << std::endl;
@TomTasche
TomTasche / appengine_static_file.java
Created November 10, 2013 10:36
reading a file from WEB-INF folder in AppEngine. lots of answers on StackOverflow are actually incorrect (most of them missing the leading slash)
InputStream stream = getServletContext().getResourceAsStream("/WEB-INF/file.txt");
@TomTasche
TomTasche / AndroidManifest.xml
Last active May 11, 2023 20:00
OAuth flow using the AccountManager on Android
<!-- ... -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- ... -->