Skip to content

Instantly share code, notes, and snippets.

View jdsingh's full-sized avatar
🎯
Focusing

Jagdeep Singh jdsingh

🎯
Focusing
View GitHub Profile
@jdsingh
jdsingh / googleMapMyLocation
Created November 14, 2015 08:02 — forked from Manabu-GT/googleMapMyLocation
Android - adjust google map's my location button
//HACK: Get the button view and place it on the bottom right (as Google Maps app)
View locationButton = ((View) mMapFragment.getView().findViewById(1).getParent()).findViewById(2);
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
rlp.setMargins(0, 0, 30, 30);
@jdsingh
jdsingh / ActivityA.java
Created February 2, 2016 07:31
Stackoverflow answer, "Singleton in Android"
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@jdsingh
jdsingh / gist:efb62008c35c9739eb45
Created February 26, 2016 09:40 — forked from tamoyal/gist:10441108
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@jdsingh
jdsingh / TimestampUtils.java
Created March 18, 2016 07:44 — forked from kristopherjohnson/TimestampUtils.java
Methods for generating ISO 8601 timestamps in Java/Android
package net.kristopherjohnson.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
/**
* Methods for dealing with timestamps
@jdsingh
jdsingh / AndroidManifest.xml
Created June 8, 2016 19:34 — forked from billmote/AndroidManifest.xml
When pushing code from your IDE, wake the device and show the activity.
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this as a debug manifest so the permissions won't be required by your production app -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
</manifest>
def dict_interdiff(d1, d2):
'''
d1, d2: dicts whose keys and values are integers
Returns a tuple of dictionaries according to the instructions above
'''
intersect = {}
difference = {}
for key in d1.keys():
if d2.has_key(key):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours 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>
@jdsingh
jdsingh / ApiModule.java
Created January 3, 2017 06:14 — forked from koesie10/ApiModule.java
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@jdsingh
jdsingh / RxFirebase.java
Created February 24, 2017 12:41 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.Constants;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
public class RxFirebase {
@jdsingh
jdsingh / DownloadManagerResolver.java
Created March 1, 2017 18:00 — forked from Folyd/DownloadManagerResolver.java
A helper class to detect whether DownloadManager is disabled in Android device,if true show AlertDialog to tell user to enable it.
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatTextView;