Skip to content

Instantly share code, notes, and snippets.

@svenporto
svenporto / gist:8f9cca625e27b4ad986a1808498cf1dd
Created May 14, 2019 13:50
Skip link on pragmaticaccess.com
== HTML
<a class="skip-main" href="#main">Skip to main content</a>
== CSS
a.skip-main {
left: -999px;
position: absolute;
top: auto;
width: 1px;
height: 1px;
@svenporto
svenporto / AndroidStorage.java
Last active August 29, 2015 14:04
Android storage helper enum
public enum AndroidStorage {
/**
* /data/data/com.mypackage.name/files
*/
INTERNAL_APPLICATION,
/**
* /storage/emulated/0
*/
EXTERNAL_ROOT,
@svenporto
svenporto / gist:4171493
Created November 29, 2012 20:01
Milliseconds to days, hours, minutes and seconds
/**
* Formats milliseconds to human readable format "3d 12h 30m 10s"
* in HTML formatting
*
* @param timeInMilliseconds
* @return
*/
public static Spanned getTimeFormatted(long timeInMilliseconds) {
int seconds = (int) (timeInMilliseconds % 60);
timeInMilliseconds /= 60;
@svenporto
svenporto / gist:4171462
Created November 29, 2012 19:58
LatLon GeoPoint - GeoPoint with double latitude and longitude
public class LatLonGeoPoint extends GeoPoint {
private double lat;
private double lon;
public LatLonGeoPoint(double lat, double lon) {
super((int) (lat*1E6), (int) (lon*1E6));
}
public double distanceTo(LatLonGeoPoint other) {
@svenporto
svenporto / gist:4171444
Created November 29, 2012 19:56
Scrollable TextView
public class ScrollableTextView extends TextView {
public ScrollableTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
rotate();
}
public ScrollableTextView(Context context, AttributeSet attrs) {
super(context, attrs);
rotate();
@svenporto
svenporto / gist:4171422
Created November 29, 2012 19:53
Enable .gitignore
// Make sure to commit your changes before
// Removes everything from the index
git rm -r --cached .
// Add all
git add .
// Commit it
git commit -m ".gitignore is now working"
@svenporto
svenporto / gist:4171399
Created November 29, 2012 19:49
Get fragment tag inside ViewPager
private String getFragmentTag(int pos){
return "android:switcher:"+R.id.pager+":"+pos;
}
@svenporto
svenporto / gist:4171366
Created November 29, 2012 19:44
Zoom map to see all GeoPoint items
private void zoomMapToSeeAllItems(MapView mapView, List<GeoPoint> items) {
int minLat = Integer.MAX_VALUE;
int maxLat = Integer.MIN_VALUE;
int minLon = Integer.MAX_VALUE;
int maxLon = Integer.MIN_VALUE;
double fitFactor = 1.5;
for (GeoPoint item : items) {
int lat = item.getLatitudeE6();
int lon = item.getLongitudeE6();