Skip to content

Instantly share code, notes, and snippets.

@EbenezerGH
EbenezerGH / Creating Gradle tasks that read scripts
Last active January 22, 2021 16:19
An example of creating a lint check before each git commit.
// Task to be added in root built.gradle
task installGitHook(type: Copy) {
from new File(rootProject.rootDir, 'pre-commit')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
tasks.getByPath(':app:preBuild').dependsOn installGitHook
------------------------------------------------------------
#script to be added to pre-commit file in project root
```
import 'dart:math';
var R = 6371e3; // earth radius
num degToRad(num deg) => deg * (pi / 180.0);
num radToDeg(num rad) => rad * (180.0 / pi);
/*
Haversine formula
fun autoScroll() {
val handler = Handler()
val runnable = object : Runnable {
override fun run() {
scrollBy(2, 0)
handler.postDelayed(this, 0)
}
}
handler.postDelayed(runnable, 0)
}
@EbenezerGH
EbenezerGH / bytes32_common_issues.md
Last active November 26, 2018 20:21
byte array must be in range 0 < M <= 32

byte array must be in range 0 < M <= 32

You can simply convert a string to a bytes32 format in kotlin or solidity

Solidity:
    function stringToBytes32(string memory source) private pure returns (bytes32 result) {
        bytes memory tempEmptyStringTest = bytes(source);
        if (tempEmptyStringTest.length == 0) {
            return 0x0;
### Keybase proof
I hereby claim:
* I am EbenezerGH on github.
* I am rezenebe (https://keybase.io/rezenebe) on keybase.
* I have a public key whose fingerprint is F8CC EEBF AF5A C7BE 904F 1D4D 1B44 B989 F73F 4F9F
To claim this, I am signing this object:
Chapter 1: Que es RxJava?
RxJava is a Java VM implementation of Reactive Extensions
Reactive Extensions: a library for composing asynchronous and event-based programes by using observables
Observable: Emits the value
Observer: Retrieves the value by subscribing to observable
Flowable, Observable, Single, Completable, Maybe: Does work and emit value
Subscription: Work is going on or completed or is used to cancel
@EbenezerGH
EbenezerGH / huelights_notes
Created August 20, 2017 02:33
few commands for arduino,hue communication.
Reference Links:
https://www.developers.meethue.com/documentation/getting-started
# Upon entry
url: /api
{"devicetype":"my_hue_app#android ebenezer"}
method: POST
# Authenticated Hue ID: (ID token changes each reset)
qtiZQ6RLayFCNVdwWsjxch33N4XqoPjZw422DWba
@EbenezerGH
EbenezerGH / To Buy...
Last active November 5, 2015 20:49
stuff to buy
http://jeffjudo.com - Stupid office stuff and tchotchkes
http://thisiswhyimbroke.com – Your source for cool, fun, useful (and sometimes useless) stuff you can find and buy on the web.
http://spruuce.com – Curated gifts for every kind of person.
http://filleritem.com – Enter the amount you need to see a list of products that qualify for free shipping from Amazon.
http://dattwenty.com – The best stuff on Amazon for under $20.
http://shutupandtakemymoney.com – The coolest and geekest products around.
http://givetu.me – Gifts outside the box for every one of your family members.
http://dodoburd.com – Find the coolest, most unique gifts for every occasion.
http://coolmaterial.com – All the gadgets and handcrafted goods that men want.
http://coolhunting.com – A daily update on ideas and products in the intersection of art, design, culture and technology.
@EbenezerGH
EbenezerGH / Abstracting Fragment Classes
Created October 18, 2015 18:04
An example of Abstracting out and calling fragments
package com.jfyg.bignerdranch.criminalintent.activities;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import com.jfyg.bignerdranch.criminalintent.R;
private void showAnswerAnimation() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int cx = mShowAnswer.getWidth() / 2;
int cy = mShowAnswer.getHeight() / 2;
float radius = mShowAnswer.getWidth();
Animator anim = ViewAnimationUtils
.createCircularReveal(mShowAnswer, cx, cy, radius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {