I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * 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 |
Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.
It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:
from the command line, either use
- git add -p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * ArcUtils.java | |
| * | |
| * Copyright (c) 2014 BioWink GmbH. | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| * copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git branch -m old_branch new_branch # Rename branch locally | |
| git push origin :old_branch # Delete the old branch | |
| git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.cyrilmottier.android.resourcesadditions; | |
| import android.content.res.Resources; | |
| import android.content.res.XmlResourceParser; | |
| import android.os.Bundle; | |
| import org.xmlpull.v1.XmlPullParser; | |
| import org.xmlpull.v1.XmlPullParserException; | |
| /** | |
| * @author Cyril Mottier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OnClickListenerActivity extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); | |
| commutateViewSwitcherButton.setOnClickListener(new OnClickListener() { | |
| public void onClick(View view) { | |
| final ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.viewSwitcher); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static Bitmap getRoundedBitmap(Bitmap bitmap) { | |
| final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); | |
| final Canvas canvas = new Canvas(output); | |
| final int color = Color.RED; | |
| final Paint paint = new Paint(); | |
| final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); | |
| final RectF rectF = new RectF(rect); | |
| paint.setAntiAlias(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <resources> | |
| <string name="config_app_name">AVélib</string> | |
| <string name="config_authority">com.cyrilmottier.android.avelib.citybikes</string> | |
| <string name="config_com.google.android.maps.v2.api_key">XXX</string> | |
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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(); |