Skip to content

Instantly share code, notes, and snippets.

View chris-piekarski's full-sized avatar

Christopher Piekarski chris-piekarski

  • Boulder, CO
  • 22:17 (UTC)
View GitHub Profile
@chris-piekarski
chris-piekarski / logcat parser
Last active May 9, 2016 23:48
Parse Android logcat file into .csv file with cols as TAGS
# Author: @c_piekarski
import optparse
import csv
import logging
import os
import datetime
import re
TAGS = ["Browser","Dalvikvm", "Zygote", "AndroidRuntime"]
SUBTAGS = [
@chris-piekarski
chris-piekarski / java_reflection_array_type
Created October 16, 2014 17:27
Java Reflection Field Array Type
if(field.getType().isArray() && field.getType() == String[].class) {
if(field.getName() == "SHORTCUT" || field.getName() == "URI") {
String[] x = (String []) field.get(field);
for(int i = 0; i < x.length; i++) {
//Do something
}
}
}
@chris-piekarski
chris-piekarski / android:layout_width
Created October 7, 2014 18:42
Layout Width/Height Constants
public static final int FILL_PARENT
Added in API level 1
Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. This value is deprecated starting in API Level 8 and replaced by MATCH_PARENT.
Constant Value: -1 (0xffffffff)
public static final int MATCH_PARENT
Added in API level 8
@chris-piekarski
chris-piekarski / jce_providers
Created September 23, 2014 17:22
Listing all JCE providers and the algorithms they support
Provider[] providers = Security.getProviders();
for (Provider p : providers) {
System.out.printf("%s/%s/%f\n", p.getName(), p.getInfo(),
p.getVersion());
Set<Service> services = p.getServices();
for (Service s : services) {
System.out.printf("\t%s/%s/%s\n", s.getType(),
s.getAlgorithm(), s.getClassName());
@chris-piekarski
chris-piekarski / aosp_dimension_types
Created September 3, 2014 16:41
AOSP Dimension Types (dp, sp, pt, px, mm, in)
A dimension value defined in XML. A dimension is specified with a number followed by a unit of measure. For example: 10px, 2in, 5sp. The following units of measure are supported by Android:
dp
Density-independent Pixels - An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, on which 1dp is roughly equal to 1px. When running on a higher density screen, the number of pixels used to draw 1dp is scaled up by a factor appropriate for the screen's dpi. Likewise, when on a lower density screen, the number of pixels used for 1dp is scaled down. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Using dp units (instead of px units) is a simple solution to making the view dimensions in your layout resize properly for different screen densities. In other words, it provides consistency for the real-world sizes of your UI elements across different devices.
sp
Scale-independent Pixels - This
@chris-piekarski
chris-piekarski / aosp_http_headers
Created August 13, 2014 20:09
Dump Android HttpRequest Headers To Logcat
public void handle(HttpRequest request, ... ) {
Header[] hdrs = request.getAllHeaders();
for( Header h: hdrs) {
Log.w(TAG, h.getName()+":"+h.getValue());
}
}
@chris-piekarski
chris-piekarski / system_aosp_libs
Created August 4, 2014 17:36
Adding system shared lib to AOSP
See device/sample/frameworks/PlatformLibrary/README.txt
Platform Library Example
~~~~~~~~~~~~~~~~~~~~~~~~
This directory contains a full example of writing your own Android platform
shared library, without changing the Android framework. It also shows how to
write JNI code for incorporating native code into the library, and a client
application that uses the library.
@chris-piekarski
chris-piekarski / syslog_real_time_crunch
Created July 22, 2014 17:29
Crunch syslog file in real-time
tail -f /var/log/syslog | stdbuf -oL cut -d'|' -f2 | tee times.txt
@chris-piekarski
chris-piekarski / ubuntu_oracle_jdk
Created July 4, 2014 01:18
Ubuntu Oracle JDK Install
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Oracle JDK 6
sudo apt-get install oracle-java6-installer
Oracle JDK 7
sudo apt-get install oracle-java7-installer
@chris-piekarski
chris-piekarski / django_notes
Last active August 29, 2015 14:03
django notes
#get version
python -c "import django; print(django.get_version())"
#create a project
django-admin.py startproject mysite
#run development server
python manage.py runserver OR python manage.py runserver 8080 OR python manage.py runserver 0.0.0.0:8000
#create databse tables from INSTALLED_APPS models