This file contains 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
# keep setters in VectorDrawables so that animations can still work. | |
-keepclassmembers class android.support.graphics.drawable.VectorDrawableCompat$* { | |
void set*(***); | |
*** get*(); | |
} |
This file contains 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
import org.junit.Assert.* | |
import org.junit.Test | |
/** | |
* @author juancho | |
*/ | |
class day1Test() { | |
val input = "()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())( |
This file contains 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
inline fun <reified T : Parcelable> createParcel( | |
crossinline createFromParcel: (Parcel) -> T?): Parcelable.Creator<T> = | |
object : Parcelable.Creator<T> { | |
override fun createFromParcel(source: Parcel): T? = createFromParcel(source) | |
override fun newArray(size: Int): Array<out T?> = arrayOfNulls(size) | |
} |
This file contains 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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val toolbar = findViewById(R.id.toolbar) as Toolbar | |
setSupportActionBar(toolbar) | |
val fab = findViewById(R.id.fab) as FloatingActionButton | |
fab.setOnClickListener { view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show() } |
This file contains 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 MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); |
This file contains 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
func getRandomColor() -> UIColor { | |
return UIColor( | |
red: CGFloat(arc4random() % 256) / 255.0, | |
green: CGFloat(arc4random() % 256) / 255.0, | |
blue: CGFloat(arc4random() % 256) / 255.0, | |
alpha: 1) | |
} |
This file contains 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
for n in 0...100 { | |
var msg = "" | |
switch(n) { | |
case 30...40: | |
msg = "Viva Swift!!!" | |
case let (x) where (x%5 == 0): | |
msg = "Bingo!!!" | |
case let (x) where (x%2 == 0): | |
msg = "par!!!" | |
case let (x) where (x%2 == 1): |
This file contains 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
// ------------ Helper extension functions: | |
// Inline function to create Parcel Creator | |
inline fun <reified T : Parcelable> createParcel(crossinline createFromParcel: (Parcel) -> T?): Parcelable.Creator<T> = | |
object : Parcelable.Creator<T> { | |
override fun createFromParcel(source: Parcel): T? = createFromParcel(source) | |
override fun newArray(size: Int): Array<out T?> = arrayOfNulls(size) | |
} | |
// custom readParcelable to avoid reflection |