Skip to content

Instantly share code, notes, and snippets.

@alterakey
alterakey / analyze-api.py
Last active August 29, 2015 14:25
Crude API usage analyzer for Android
# analyze-api: Crude API usage analyzer for Android
# Copyright (C) 2015 Takahiro Yoshimura <altakey@gmail.com>. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
.Reservations[].Instances[]|{name:(.Tags[]|select(.Key=="Name").Value), iid:.InstanceId, ip:(.NetworkInterfaces[].Association.PublicIp)}
'.Reservations[].Instances[]|select(.Tags[]|select(.Key=="Name").Value == "instance_name")|.InstanceId'
@alterakey
alterakey / egg.hs
Created April 8, 2015 17:59
egg launcher exercise in haskell
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as I
egg x pad y = T.take x $ T.justifyLeft x pad y
repetitive_egg x pad y = egg x pad $ T.replicate (1 + (div x $ T.length y)) y
main = I.putStrLn . repetitive_egg 20 '\x90' $ T.pack "\x11\x22\x33\x44"
@alterakey
alterakey / build.gradle
Last active August 29, 2015 14:12
AGP product flavor example (0.8)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
@alterakey
alterakey / fastcgi_params_cakephp
Created December 3, 2014 16:19
nginx configuration for CakePHP 2.0.3
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@alterakey
alterakey / AttributedHandler.java
Created October 14, 2014 04:58
postDelayed() with tokens
package com.gmail.altakey.bette.hack;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
public class AttributedHandler extends Handler {
public AttributedHandler() {
}
@alterakey
alterakey / trace
Created July 1, 2014 04:20
joanne stack trace on L
E/AndroidRuntime(19660): FATAL EXCEPTION: main
E/AndroidRuntime(19660): Process: com.gmail.altakey.joanne, PID: 19660
E/AndroidRuntime(19660): java.lang.RuntimeException: Unable to start service com.gmail.altakey.joanne.service.TweetBroadcastService@2f3f1a05 with null: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getAction()' on a null object reference
E/AndroidRuntime(19660): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2789)
E/AndroidRuntime(19660): at android.app.ActivityThread.access$2100(ActivityThread.java:143)
E/AndroidRuntime(19660): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
E/AndroidRuntime(19660): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(19660): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(19660): at android.app.ActivityThread.main(ActivityThread.java:5070)
@alterakey
alterakey / OkHttpStack.java
Last active August 29, 2015 14:03 — forked from JakeWharton/OkHttpStack.java
OkHttpStack ported to OkHttp 2.0
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.OkUrlFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Ported to OkHttp 2.0, based on https://gist.github.com/JakeWharton/5616899 .
*
@alterakey
alterakey / gitignore-android-studio
Created June 9, 2014 17:03
.gitignore for Android Studio projects
.gradle
build
gradle.xml
local.properties
/.idea/dictionaries
/.idea/dataSources.ids
/.idea/dataSources.xml
/.idea/libraries
/.idea/workspace.xml
/.idea/tasks.xml
@alterakey
alterakey / counter.go
Created June 2, 2014 03:09
Counting request in Go
package hello
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", handler)
}