Skip to content

Instantly share code, notes, and snippets.

@TomTasche
TomTasche / Gruntfile.js
Created Dec 27, 2015
dispatcher for multi-module appengine setups
View Gruntfile.js
// ...
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 Sep 1, 2014
commands i used to extract the ssl-certificate from a running system for usage with heroku
View extract-certificate.sh
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
View IDViewController.m
//
// 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
ndk-gdb of NDK r9d modified to *always* debug the ":remote"-process of your app
View ndk-gdb-remote
#!/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
#
View resize_disk_image.sh
#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 Dec 31, 2015
console output in C++
View debug_log.cpp
std::cout << "debug message: " << array.size() << std::endl;
@TomTasche
TomTasche / appengine_static_file.java
Created Nov 10, 2013
reading a file from WEB-INF folder in AppEngine. lots of answers on StackOverflow are actually incorrect (most of them missing the leading slash)
View appengine_static_file.java
InputStream stream = getServletContext().getResourceAsStream("/WEB-INF/file.txt");
@TomTasche
TomTasche / AndroidManifest.xml
Last active Feb 9, 2021
OAuth flow using the AccountManager on Android
View AndroidManifest.xml
<!-- ... -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<!-- ... -->
@TomTasche
TomTasche / appengine.java
Created May 9, 2013
a demonstration of a file upload without any additional libraries on Android. More information here: http://blog.tomtasche.at/2013/05/android-upload-file-to-appengine.html
View appengine.java
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try {
InputStream stream = req.getInputStream();
// do whatever you want with the stream now
} catch (Exception ex) {
throw new ServletException(ex);
}
@TomTasche
TomTasche / GTalkOAuthSASLMechanism.java
Last active Dec 17, 2015
this gist describes how to 1. get an OAuth token from Android's AccountManager, 2. use this token to connect with GTalk via XMPP. Blog post about it: http://blog.tomtasche.at/2013/05/gtalk-and-oauth-on-android.html
View GTalkOAuthSASLMechanism.java
// taken from: http://stackoverflow.com/a/10712949/198996
// note: you don't have to change anything in this class
public class GTalkOAuthSASLMechanism extends SASLMechanism {
public static final String NAME = "X-GOOGLE-TOKEN";
public GTalkOAuthSASLMechanism(SASLAuthentication saslAuthentication) {
super(saslAuthentication);
}