Skip to content

Instantly share code, notes, and snippets.

View sendtomitesh's full-sized avatar

Mitesh Patel sendtomitesh

View GitHub Profile
@sendtomitesh
sendtomitesh / gist:d50e31c13b30e04a27fa62ca79e6e132
Created September 19, 2017 07:05 — forked from mhawksey/gist:5705633
Google Apps Script to send emails when an new Google Site Announcement is made (In response to https://plus.google.com/109310290306060614500/posts/JYMPQ2mLuEt )
/*
1. Set two variables below
2. Run > setup (twice, once to authenticate the script, second to actually run
3. Rescources > Current project trigger's and then click 'No triggers set up. Click here to add one now.'
You can accept the defaults to run emailAnnouncements() every hour
*/
var url_of_announcements_page = "https://sites.google.com/site/appsscripttemplates/home/announcetest"; // where your site page is
var who_to_email = "youremail@example.com" // who to send to (it can be a comma seperated list)
@sendtomitesh
sendtomitesh / MediaPlayerStateWrapper.java
Created April 6, 2016 06:15 — forked from bitops/MediaPlayerStateWrapper.java
A drop-in replacement for a MediaPlayer instance, that provides an accessor for the current state.
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import android.media.AudioManager;
import android.media.MediaPlayer;
@sendtomitesh
sendtomitesh / Logcat.java
Created March 10, 2016 08:12 — forked from Antarix/Logcat.java
Simple extension of android Logcat class which makes easy to change debugging mode.
import android.util.Log;
public class Logcat{
/*
* ALLOW_LOG to enable or disable debugging log
*/
private static final boolean ALLOW_LOG = true;
@sendtomitesh
sendtomitesh / Imaging.php
Created October 13, 2015 11:32 — forked from Antarix/Imaging.php
Create thumbnail of image while uploading
<?php
class Imaging
{
// Variables
private $img_input;
private $img_output;
private $img_src;
private $format;
@sendtomitesh
sendtomitesh / MultiPartUtility.java
Created October 13, 2015 09:32 — forked from Antarix/MultiPartUtility.java
Uploading Multiple files at once with Post and Header parameter in Android
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Use this color for listview background or your layout #e5e5e5 -->
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp"/>
<solid android:color="#ccc" />
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import android.text.format.DateUtils;
public class TimeUtils {
public static final String DD_MM_YY_HH_MM = "dd-MMM-yy h:mm";
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import android.text.format.DateUtils;
public class TimeUtils {
public static final String DD_MM_YY_HH_MM = "dd-MMM-yy h:mm";