Skip to content

Instantly share code, notes, and snippets.

View stormzhang's full-sized avatar

stormzhang stormzhang

View GitHub Profile
@wdiechmann
wdiechmann / time_zone_io.md
Created November 13, 2012 14:21
time and time again, your rails will come clean :)

Started out with that frustrating issue that bites many a Rails developer (judging from just a tad over 24hrs googling and reading blogs etc) - time_zone!

I'm on

ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.4.2] - Rails 3.2.8
config.time_zone = 'Copenhagen'

and initially, I wanted to bark up this three, 'with the pack'

[31] pry(main)> ent.enter_at=Time.now 
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class

mkdown

What is this?

Mkdown renders Markdown GitHub gists with alternative CSS. Use it to elegantly share gists written in Markdown.

How do I use this?

To create your own mkdown URL, append the gist ID in a URL of the form: http://mkdown.com/{GIST ID}. The gist ID is the string at the end of a gist URL.

@deepankarb
deepankarb / svg-to-android.sh
Last active July 14, 2018 13:13
A script to generate android assets from a SVG file. Requires inkscape to resize and convert.
#!/bin/bash
if [[ -z "$1" ]];
then
echo "No SVG file specified. Exiting."
exit -1
fi
ispng=$(file $1)
echo $ispng | grep -q SVG
@benvd
benvd / FadeInNetworkImageView.java
Created May 31, 2013 09:16
Extension of Volley's NetworkImageView that fades in images as they're loaded
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.*;
import android.util.AttributeSet;
import com.android.volley.toolbox.NetworkImageView;
public class FadeInNetworkImageView extends NetworkImageView {
private static final int FADE_IN_TIME_MS = 250;
@romannurik
romannurik / CharsPerLineActivity.java
Last active December 17, 2021 03:15
Demonstrates how to identify and avoid line-length issues with TextView. The measure, or characters per line, of a block of text plays a key role in how comfortable it is to read (sometimes referred to as readability). A widely accepted optimal range for a text block's measure is between 45 and 75 characters. This code demonstrates two phases of…
/*
* Copyright 2013 Google Inc.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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
@JakeWharton
JakeWharton / OkHttpStack.java
Created May 21, 2013 01:14
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder