Skip to content

Instantly share code, notes, and snippets.

View mttkay's full-sized avatar

Matthias Käppler mttkay

  • GitLab
  • Berlin, Germany
View GitHub Profile
<TextView android:id="@+id/my_text" ...>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_text" type="id" />
</resources>
TextView text = (TextView) findViewById(R.id.my_text);
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="my_textview_style" parent="@android:style/Widget.TextView">
<item name="android:id">@+id/my_text</item>
...
</style>
</resources>
<TextView style="@style/my_textview_style" .../>
@mttkay
mttkay / DownloadTask.java
Last active December 21, 2015 16:19
An AsyncTask.
class DownloadTask extends AsyncTask<String, Void, File> {
protected File doInBackground(String... args) {
final String url = args[0];
try {
byte[] fileContent = downloadFile(url);
File file = writeToFile(fileContent);
return file;
} catch (Exception e) {
// ???
@mttkay
mttkay / gist:3851440
Created October 8, 2012 08:40
Testing if an Android app is installed on the SD card
private boolean isAppInstalledToSDCard(Context context) {
PackageManager pm = context.getPackageManager();
try {
int extStorage = ApplicationInfo.FLAG_EXTERNAL_STORAGE;
String package = context.getPackageName();
ApplicationInfo appInfo = pm.getApplicationInfo(package, extStorage);
return extStorage == (extStorage & appInfo.flags);
} catch (NameNotFoundException e) {
e.printStackTrace();
return false;
@mttkay
mttkay / report.txt
Created June 15, 2016 07:12
Mix 1.0.5 crash
Process: Mix-ide [31034]
Path: /Applications/Mix-ide.app/Contents/MacOS/Mix-ide
Identifier: .
Version: ??? (mix )
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Mix-ide [31034]
User ID: 502
Date/Time: 2016-06-15 09:09:57.574 +0200
@mttkay
mttkay / geth.log
Created June 15, 2016 07:39
get --fast logs
I0615 09:11:30.700609 core/blockchain.go:751] imported 6 receipt(s) (0 ignored) in 1.002706ms. #372705 [bb0cce10… / 690c5ba5…]
I0615 09:11:31.994642 core/blockchain.go:751] imported 17 receipt(s) (0 ignored) in 2.624429ms. #372722 [5185b9fa… / 8c6fe057…]
I0615 09:11:32.029927 core/headerchain.go:294] imported 178 header(s) (14 ignored) in 24.758826ms. #374733 [297a5f22… / bb1ef962…]
I0615 09:11:32.602010 core/blockchain.go:751] imported 14 receipt(s) (0 ignored) in 1.509627ms. #372736 [e00911b5… / ccbd5a6b…]
I0615 09:11:32.914538 core/headerchain.go:294] imported 192 header(s) (0 ignored) in 22.871789ms. #374925 [c03127ff… / bcffe252…]
I0615 09:11:32.942771 core/blockchain.go:751] imported 19 receipt(s) (0 ignored) in 11.930873ms. #372755 [1c601c38… / 7a58945a…]
I0615 09:11:33.500175 core/blockchain.go:751] imported 20 receipt(s) (0 ignored) in 4.984327ms. #372775 [3de5382c… / 639f5c5f…]
I0615 09:11:33.536139 core/headerchain.go:294] imported 192 header(s) (0 ignored) in 27.151351ms. #375117 [a858cb8f… / 11d1
@mttkay
mttkay / coffee.scala
Last active September 4, 2018 21:00
Passing functions, not objects as collaborators
class Coffee
class Order
class CoffeeMaker {
def startCoffee(): Unit = ???
def isCoffeeReady: Boolean = ???