Skip to content

Instantly share code, notes, and snippets.

@arifnoumankhan
arifnoumankhan / CountingFileRequestBody.java
Created April 8, 2017 19:27 — forked from eduardb/CountingFileRequestBody.java
Uploading a file with a progress displayed using OkHttp
public class CountingFileRequestBody extends RequestBody {
private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
private final File file;
private final ProgressListener listener;
private final String contentType;
public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
this.file = file;
private void selectImage() {
final CharSequence[] items = { "Take Photo", "Choose from Library",
"Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Add Photo!");
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals("Take Photo")) {
try {
private void login() {
String email=wrapperEmail.getEditText().getText().toString().trim();
String password=wrapperPassword.getEditText().getText().toString().trim();
if (email.isEmpty()) wrapperEmail.setError("Email Required...!"); else wrapperEmail.setError(null);
if (password.isEmpty()) wrapperPassword.setError("Password Required...!");else wrapperPassword.setError(null);
if (!email.isEmpty() && !password.isEmpty())
{
if (new Utilities().validateEmail(email)) {
wrapperEmail.setError(null);
@arifnoumankhan
arifnoumankhan / linux_fun.md
Created June 26, 2016 22:32 — forked from marianposaceanu/linux_fun.md
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@arifnoumankhan
arifnoumankhan / gist:7f5b9bfc039ba35fe053ad115067e9b6
Created June 24, 2016 19:09 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@arifnoumankhan
arifnoumankhan / MyActivity.java
Created June 20, 2016 20:22 — forked from markushi/MyActivity.java
Reveal Color View Demo
package at.markushi.reveal;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.view.View;
import at.markushi.ui.RevealColorView;
@arifnoumankhan
arifnoumankhan / README.md
Created March 17, 2016 11:39
A click / long press listener for RecyclerViews. Questions? https://twitter.com/lnikkila
@arifnoumankhan
arifnoumankhan / RecyclerViewCustomAdapter.java
Created February 25, 2016 05:55
RecyclerView Custom Adapter which have one image 2 text views and a button for deleting rows from recyclerview.
public class RecyclerViewCustomAdapter extends RecyclerView.Adapter<RecyclerViewCustomAdapter.SimpleViewHolder> {
String[] dataset;
Context context;
ArrayList<String> datasetList=new ArrayList<>();
// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
@arifnoumankhan
arifnoumankhan / H2app.java
Created October 17, 2015 08:03 — forked from jewelsea/H2app.java
Sample for accessing a local database from JavaFX.
import java.sql.*;
import java.util.logging.*;
import javafx.application.Application;
import javafx.collections.*;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;