Skip to content

Instantly share code, notes, and snippets.

View ademar111190's full-sized avatar
Lightning Networking the Bitcoin

Ademar ademar111190

Lightning Networking the Bitcoin
  • CEO of Bitcoin
  • Itatiba
View GitHub Profile
@ademar111190
ademar111190 / README.md
Last active August 29, 2015 14:22
A little example of how manipulate matrix with threads in C

#A little example of how manipulate matrix with threads in C

  • compile:

$ gcc -pthread squareMatrixItemsWithThreads.c -o squareMatrixItemsWithThreads

  • run

$ ./squareMatrixItemsWithThreads

@ademar111190
ademar111190 / rippleManually.java
Created April 1, 2015 22:36
Just an way to create ripple drawables in java code
// TODO test if works
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][] { new int[] { android.R.attr.state_pressed } };
int[] colors = new int[] { color };
ColorStateList colorStateList = new ColorStateList(states, colors);
RippleDrawable rippleDrawable = new RippleDrawable(colorStateList, null, null);
view.setBackground(rippleDrawable);
}
@ademar111190
ademar111190 / lambdaExample.java
Last active January 14, 2018 20:03
One month with Kotlin: lambda example
// Using Lambdas on Kotlin
val items = ArrayList<String>()
items.sortBy { item ->
item.length()
}
//or more implicity
items.sortBy { it.length() }
//------------------------------------------------------------------------------
@ademar111190
ademar111190 / nullableExample.java
Last active August 29, 2015 14:17
One month with Kotlin: nullable example
// Using Nullables on Kotlin
var nothing = null
var stringNullable: String? = null
//------------------------------------------------------------------------------
// Using Nullables in Java 7
String alwaysCanBeNull = null
@ademar111190
ademar111190 / classFieldsExample.java
Last active August 29, 2015 14:17
One month with Kotlin: class fields example
// Using Class Fields on Kotlin
public class Foo(var variable: String, val value: String, val withDefault: String = "o") {
}
// And use it on Kotlin
Foo("f", "o", "o")
Foo("f", "o")
//------------------------------------------------------------------------------
@ademar111190
ademar111190 / variableExample.java
Last active August 29, 2015 14:17
One month with Kotlin: variable example
// Using Variables on Kotlin
var foo = "mutable foo"
val finalFoo = "final foo"
val explicitFoo: String = "explicit foo"
//------------------------------------------------------------------------------
// Using Variables in Java 7
@ademar111190
ademar111190 / singletonExample.java
Last active September 22, 2017 08:29
One month with Kotlin: singleton example
// Using Singleton on Kotlin
public object MySingleton {
public fun foo() {
}
}
// And use it on Kotlin
MySingleton.foo()
@ademar111190
ademar111190 / closureExample.java
Last active August 29, 2015 14:17
One month with Kotlin: closure example
// Using Closure on Kotlin
button.setOnClickListener {
Thread {
// Amazing! Just 2 identations, 5 lines and 55 characters "lesser than a half of tweet"
}.start()
}
//------------------------------------------------------------------------------
// Using the nearest from Closure in Java 7
@ademar111190
ademar111190 / lazyExample.java
Last active August 29, 2015 14:17
One month with Kotlin: lazy example
// Using Lazy on Kotlin
private val foo by Delegates.lazy { Foo(getContext()) }
//------------------------------------------------------------------------------
// Using the nearest from Lazy in Java 7
private Foo mFoo;
public Foo getFoo() {
if (mFoo == null) {
@ademar111190
ademar111190 / exhaustion
Created March 7, 2015 21:34
Verify if 0 + 1 + 2 + ... + n is equals to (n * (n + 1)) / 2 by exhaustion
#!/usr/bin/env python
from time import time
'''
Verify if 0 + 1 + 2 + ... + n is equals to (n * (n + 1)) / 2, this
method is not using mathematical induction, it is using exhaustion
'''
def proof(n):
for i in range(n + 1):