Skip to content

Instantly share code, notes, and snippets.

@alterakey
alterakey / MainActivity.java
Created February 13, 2014 15:10
ArrayAdapter Illustration
package com.gmail.altakey.count;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
@alterakey
alterakey / ThrowableCursorLoader.java
Last active August 29, 2015 13:57
A CursorLoader implmentation that enable it to delay handling of the exceptions in loading cursors
/**
* ThrowableCursorLoader: CursorLoader for CPs that tend to throw.
*
* Copyright 2014 Takahiro Yoshimura
*
* 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
@alterakey
alterakey / dumper.c
Created April 6, 2014 14:51
An Rudimental ELF Dumper (for my own learning)
/* dumper.c: An rudimental memory dumper for hunting some executable ELF images targetting Linux 2.4 and later on x86, for my own learning project.
* Copyright (C) 2014 Takahiro Yoshimura <altakey@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@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)
}
@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 / 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 / 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 / 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 / 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 / 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"