Sublime Text 2 Shortcuts (OS X) Cheat Sheet

网上转的,mark下
Editing – Sublime Text 2
Keyp­ress Comm­and
⌘ + X Delete line
⌘ + ↩ Insert line after
⌘ + ⇧ + ↩ Insert line before
⌘ + ⌃ + ↑ Move line/s­ele­ction up
⌘ + ⌃ + ↓ Move line/s­ele­ction down
⌘ + L Select line (repea­table)
⌘ + D Select word (repea­table)
⌃ + M Jump to closing parent­heses (repea­table)
⌃ + ⇧ + M Select contents of current parent­heses
⌘ + K, ⌘ + K Delete from cursor to end of line
⌘ + K + ⌫ Delete from cursor to start of line
⌘ + ] Indent current line(s)
⌘ + [ Un-indent current line(s)
⌘ + ⇧ + D Duplicate line(s)
⌘ + J Join line below to current line
⌘ + / Commen­t/u­n-c­omment line/s­ele­ction
⌘ + ⌥ + / Block comment current selection
⌘ + ⇧ + V Paste and indent correctly

Text Manipulation – Sublime Text 2
Keyp­ress Comm­and
⌘ + K, ⌘ + U Transform to Uppercase
⌘ + K, ⌘ + L Transform to Lowercase
Find / Replace – Sublime Text 2
Keyp­ress Comm­and
⌘ + F Find
⌘ + ⌥ + F Replace
⌘ + ⇧ + F Find in files

General – Sublime Text 2
Keyp­ress Comm­and
⌘ + P Quick-open files by name
⌘ + K, ⌘ + B Toggle side bar
⌥ + ⌘ + 2 Split editor into two columns
⌥ + ⌘ + 1 Revert editor to single column

textAppearance attr of TextView widget

android系统为TextView预设了几种文本样式属性,分别为textAppearanceSmall,textAppearance,textAppearanceMedium,textAppearanceLarge。
使用的时候只需要引用上述的一种即可,默认的为textAppearanceSmall,下面的是个例子
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Hello" />

这些属性默认的textSize大小分别为14sp,16sp,18sp,22sp。当然,你可以在自己theme中改变这些默认值。

style your custom view

some breif steps to style ur custom widget(MyCircleView for example).
1.define styleable theme item
<declare-styleable name="MyWidget">
<attr name="myCircleStyle" format="reference" />
</declare-styleable>

2.define styleable attributes
#a circle has a radius and a center-position(presented by centerX and centerY)
<declare-styleable name="MyCircle">
<attr name="centerX" format="integer" />
<attr name="centerY" format="integer" />
<attr name="radius" format="dimension" />
</declare-styleable>

3.obtain styled attributes
#implement other methods(onMeasure,onDraw,onTouchEvent,etc)
public class MyCircleView extends View {
public MyCircleView(Context context) {
this(context, null);
}
public MyCircleView(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.myCircleStyle);
}
public MyCircleView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyCircle, defStyle, 0);
int centerX = a.getInteger(R.styleable.MyCircle_centerX, 100);
int centerY = a.getInteger(R.styleable.MyCircle_centerY, 100);
float radius = a.getDimension(R.styleable.MyCircle_radius, 50);
a.recycle();
}
}

4.define widget style
<style name="MyCircleStyle">
<item name="centerX">200</item>
<item name="centerY">200</item>
<item name="radius">100dp</item>
</style>

5.use your defined style in theme or layout
<style name="MyTheme" parent="android:Theme.Holo">
<item name="myCircleStyle">@style/MyCircleStyle</item>
</style>

or
<com.example.widget.MyCircleView
android:layout_width="match_parent"
android:layout_height="200dp"
style="@style/MyCircleView"
/>

Intellij IDEA

好吧,这是一篇赞美贴。
我想,每个程序员都有多个情人,如果在IDE里面选择的话,对我而言,非IDEA莫属,尽管我们才见面两天。
也许是厌倦了Mac下Eclipse那蜗牛般的速度,也许想尝试点新东西,也许想追求点另类,不管怎么说,我已经投入到了IDEA的怀抱。
IDEA给了我激情,对一个程序员来说,还有比这更让人神魂颠倒的东西吗。

android设置dialog样式的activity的宽度

只要指定activity的theme为”android:style/Theme.Dialog”,就可以以Dialog的样式显示该activity,但是dialog并不以layout中指定的layout_width=”match_parent”方式进行显示。解决方法如下:
// 设置对话框的宽度为全屏
setContentView(R.layout.layout);
LayoutParams params = getWindow().getAttributes();
params.width = LayoutParams.MATCH_PARENT;
getWindow().setAttributes(params);

解决ActionBarSherlock在部分meizu机器上不能正常使用的问题

ActionBarSherlock是一个为各种android版本手机提供actionbar支持的库。
但是在部分meizu机型上会出现InflateException异常,导致不能正常使用,这儿为具体的issue,确定原因为meizu rom的问题。
具体解决方法请参考ActionBarSherlock自定义和魅族手机的冲突解决

git恢复之前的几个提交

需求:抹除掉之前的几个commit并合并成一个最新的commit。
假设提交历史如下…c1-c2-c3-c4-c5…HEAD,现需要移除c2和c3的修改,并生成一个新的commit
步骤如下:
git revert –no-commit c3
git revert –no-commit c2
git commit -am ‘your message’

注意:如果revert过程中有冲突,则要按照提示去解决冲突
这里有篇参考revert-multiple-git-commits