Skip to content

Instantly share code, notes, and snippets.

View Ashish0988's full-sized avatar

Ashish Lingayat Ashish0988

View GitHub Profile
//Credits Tomohiko Sakamoto's Algorithm : https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
//to find the day of week from any given date.
int dow(int y, int m, int d) {
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
@Ashish0988
Ashish0988 / 0_reuse_code.js
Created November 24, 2016 09:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//Setup anim with desired properties
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE); //Repeat animation indefinitely
anim.setDuration(300);
// imgView.setAnimation(anim);
import android.content.res.AssetManager;
import android.graphics.Rect;
import android.util.SparseArray;
import com.google.android.gms.maps.model.Tile;
import com.google.android.gms.maps.model.TileProvider;
import java.io.ByteArrayOutputStream;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStreamReader;
private static final String TAG = "GateMe";
private static final int BUFFER_SIZE = 0x1000;
public static String formatDateString(String dateString) {
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); //2011-08-08 20:00:00, 2013-10-20T19:00:00Z
Date date = null;
import android.app.AlarmManager;
import android.content.Context;
import android.content.Intent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
private final static int SECONDS = 1;
private final static int MINUTES = 60 * SECONDS;
private final static int HOURS = 60 * MINUTES;
private final static int DAYS = 24 * HOURS;
private final static int WEEKS = 7 * DAYS;
private final static int MONTHS = 4 * WEEKS;
private final static int YEARS = 12 * MONTHS;
/**
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
/**
* A special variation of RelativeLayout that can be used as a checkable object.
* This allows it to be used as the top-level view of a list view item, which