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 / hexa.py
Created April 22, 2014 18:18
A script to generate current timestamp in hexadecimal
#!/usr/bin/python
'''
A script to generate current timestamp in hexadecimal
'''
from time import time
print hex(int(time()))
@ademar111190
ademar111190 / SearchViewFormatter.java
Last active March 16, 2023 10:44
An easy way to format SearchView's
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SearchView;
import android.widget.TextView;
@ademar111190
ademar111190 / gist:453d5a7a4e75e7e5933f
Created June 26, 2014 21:25
Android & Java brazilian CPF and CEP pattern
import java.util.regex.Pattern;
public static final Pattern CPF = Pattern.compile("^([0-9]{3}\\.?){3}-?[0-9]{2}$");
public static final Pattern CEP = Pattern.compile("[0-9]{5}-?[0-9]{3}");
@ademar111190
ademar111190 / MyItemAnimator
Created August 20, 2014 18:00
Playing with ItemAnimator in the new Android RecyclerView
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import java.util.ArrayList;
import java.util.List;
@ademar111190
ademar111190 / alah
Created October 22, 2014 16:32
Show one of ninety nine allah`s names
#!/usr/local/bin/lua
Alah = {}
Alah.__index = Alah
function Alah:new(latin, arabic, portuguese)
o = {}
setmetatable(o, self)
self.__index = self
self.latin = latin
@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):
@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 / 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 / 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 / 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