Skip to content

Instantly share code, notes, and snippets.

@doridori
doridori / ViewTreeObserver_Ex.java
Last active August 29, 2015 13:56
Grabbing content view dimensions via ViewTreeObserver - all Display methods have no guarantee if they will include system and status bars in height
//inside a fragment. If in an Activity you could use findViewById(Window.ID_ANDROID_CONTENT);
getView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
//do something like measure a view etc
View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT);
Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight());
@johnbear724
johnbear724 / gist:c189782efd1eaa63ddea
Last active August 29, 2015 14:08
使用Drawables

该文档翻译自 Android 5.0 文档中对 Material Design 的介绍,原文地址:http://developer.android.com/training/material/drawables.html

Drawables 的以下功能帮助你在你的应用中实现 Material Design:

  • 将图像染色
  • 提取图像中的显著颜色
  • 矢量图像(Vector Drawables)

该课程向你展示如何在你的应用中使用这些特性。

@jeroenvandijk
jeroenvandijk / rails_test_box_prepackaged.sh
Created May 4, 2010 16:32
Instructions for setting up the prepackaged Rails test environment
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
@tmilewski
tmilewski / railscasts.rb
Created January 2, 2011 09:37
Download all Railscasts Episodes
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = open('http://railscasts.com/') { |f| Hpricot(f) }
total_episodes = (doc/'div.number').first.inner_html[1,3].to_i
total_pages = (total_episodes / 10).ceil
(1..total_pages).each do |i|
puts "PAGE #{i} ================================"
@D3xx73r
D3xx73r / deploy.rb
Created April 30, 2012 20:48
Capistrano deploy file
require "bundler/capistrano"
# Define your server here
server "<server>", :web, :app, :db, primary: true
# Set application settings
set :application, "<app_name>"
set :user, "<deployment_user>" # As defined on your server
set :deploy_to, "/home/#{user}/apps/#{application}" # Directory in which the deployment will take place
set :deploy_via, :remote_cache
@xdite
xdite / 2017-06-01.md
Last active June 22, 2017 07:18
参与全栈学习这么久,你觉得自己和之前最大的不同是? (直播问卷答案-共94份答案)

参与全栈学习这么久,你觉得自己和之前最大的不同是?

对编程有了系统的概念,之前总是从入门到放弃,这次终于自己能够做出完整的作品,对于自己学习其它技能的自信心也大大增强了,自己的小创意有了实现的能力,对于编程的越来越有热情。

关于全栈,之前一直觉得自己很全能,什么都会一点,但是在参加 jdstore 比赛的时候发现,一个人的时间是非常有限的,和他人配合能够大大的提高效率,大家一起做才能够在有限的时间内完成理想中的工作量,所以自己会做是一方面,懂得和人配合,团队之间的沟通也非常重要。

参与全栈学习这么久,你觉得自己和之前最大的不同是?

  1. 学会了主动学习,对自己更加自信,不再惧怕挑战。
  2. 每日写orid,让自己的逻辑更加清楚。
@keyboardr
keyboardr / FragmentUtils.java
Last active March 8, 2019 05:30
Utility method for getting the appropriate parent of a Fragment for a given callback interface.
import android.support.v4.app.Fragment;
public class FragmentUtils {
/**
* @param fragment
* The Fragment whose parent is to be found
* @param parentClass
* The interface that the parent should implement
* @return The parent of fragment that implements parentClass,
@mcxiaoke
mcxiaoke / ProxySettings.java
Created February 7, 2014 05:56
Proxy Settings for Android WebView
package com.mcxiaoke.urlexpander;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.net.Proxy;
import android.os.Build;
import android.os.Parcelable;
import android.util.ArrayMap;
import org.apache.http.HttpHost;
@gmodarelli
gmodarelli / Setup Solarized for Gnome on Ubuntu 13.04.md
Last active July 14, 2020 15:59
Setup Solarized for Gnome on Ubuntu 13.04

Dark version

wget --no-check-certificate https://raw.github.com/seebi/dircolors-solarized/master/dircolors.ansi-dark
mv dircolors.ansi-dark .dircolors
eval `dircolors ~/.dircolors`

git clone https://github.com/sigurdga/gnome-terminal-colors-solarized.git
cd gnome-terminal-colors-solarized
./set_dark.sh
@romannurik
romannurik / AndroidCreateGhostIcon.java
Created June 14, 2013 06:28
Android ColorMatrixColorFilter example: Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable). In the ghost bitmap, the RGB values take on the values from the 'color' argument, while the alpha values are derived from the source's grayscaled RGB values. The effect is that you can see through darker parts of the …
/**
* Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable).
* In the ghost bitmap, the RGB values take on the values from the 'color' argument, while
* the alpha values are derived from the source's grayscaled RGB values. The effect is that
* you can see through darker parts of the source bitmap, while lighter parts show up as
* the given color. The 'invert' argument inverts the computation of alpha values, and looks
* best when the given color is a dark.
*/
private Bitmap createGhostIcon(Drawable src, int color, boolean invert) {
int width = src.getIntrinsicWidth();