Skip to content

Instantly share code, notes, and snippets.

View gabriel-TheCode's full-sized avatar
🏠
Working from home

Gabriel TEKOMBO gabriel-TheCode

🏠
Working from home
View GitHub Profile
@gabriel-TheCode
gabriel-TheCode / JSONParser.jar
Last active August 2, 2017 13:44
Java Android JSON Parser Class
// A powerful json parser to make httprequest
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
@gabriel-TheCode
gabriel-TheCode / colors.xml
Last active December 29, 2017 09:04
Android Material Design Colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colors from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
@gabriel-TheCode
gabriel-TheCode / functions.php
Created March 6, 2019 16:19
PHP pagination function for Wordpress
<?php
$items_per_page = 2;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$offset = ( $page * $items_per_page ) - $items_per_page;
$query = 'SELECT * FROM '.$table_name;
$total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table";
$total = $wpdb->get_var( $total_query );
$results = $wpdb->get_results( $query.' ORDER BY id DESC LIMIT '. $offset.', '. $items_per_page, OBJECT );
/*
*
@gabriel-TheCode
gabriel-TheCode / books.json
Created March 27, 2019 11:06 — forked from nanotaboada/books.json
A sample collection of books in JSON format
{
"books": [
{
"isbn": "9781593275846",
"title": "Eloquent JavaScript, Second Edition",
"subtitle": "A Modern Introduction to Programming",
"author": "Marijn Haverbeke",
"published": "2014-12-14T00:00:00.000Z",
"publisher": "No Starch Press",
"pages": 472,
@gabriel-TheCode
gabriel-TheCode / SineView.java
Last active April 30, 2019 08:46 — forked from raviteja83/SineView.java
sinewave
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
@gabriel-TheCode
gabriel-TheCode / Collapsing_toolbar_layout.xml
Last active September 19, 2019 10:01
Collapsing View for bank card details
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BankCardDetailsActivity"
android:background="@color/md_white_1000"
@gabriel-TheCode
gabriel-TheCode / BounceScrollView.java
Last active September 19, 2019 10:12
An Android costomized ScrollView which implements UIScrollView over-scrolling effect of iOS.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.MarginLayoutParamsCompat;
import androidx.core.view.ViewCompat;
import androidx.core.widget.NestedScrollView;
@gabriel-TheCode
gabriel-TheCode / NonSwipeableViewPager.java
Last active September 19, 2019 10:00
Java Android code for a custom Non swipeable Viewpager
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
import androidx.viewpager.widget.ViewPager;
import java.lang.reflect.Field;
@gabriel-TheCode
gabriel-TheCode / PinEntryEditText.java
Last active September 19, 2019 10:02
An PIN EditText widget for Android
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.text.Editable;
import android.util.AttributeSet;
@gabriel-TheCode
gabriel-TheCode / ScreenUtils.java
Created September 19, 2019 09:58
Java Android utility methods for screens
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
public class ScreenUtils {
Context ctx;
DisplayMetrics metrics;