Skip to content

Instantly share code, notes, and snippets.

View dharmakshetri's full-sized avatar

Dharma Kshetri dharmakshetri

View GitHub Profile
@dharmakshetri
dharmakshetri / AndroidManifest.xml
Created October 14, 2019 14:15 — forked from BrandonSmith/AndroidManifest.xml
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
@dharmakshetri
dharmakshetri / TLSSocketFactory.java
Created March 19, 2019 14:04 — forked from fkrauthan/TLSSocketFactory.java
Custom SSLSocketFactory Implementation to enable tls 1.1 and tls 1.2 for android 4.1 (16+)
package net.cogindo.ssl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
@dharmakshetri
dharmakshetri / git_cheat-sheet.md
Created August 25, 2017 00:57 — forked from davfre/git_cheat-sheet.md
git commandline cheat-sheet
@dharmakshetri
dharmakshetri / RxJava.md
Created December 13, 2016 08:50 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
boolean hasUpdated = false;
boolean doneBuffering = false;
long bufferTimeout = 500;
// put this somewhere smart
new Thread(new Runnable() {
public void run() {
while(!doneBuffering) {
Thread.sleep(bufferTimeout);
@dharmakshetri
dharmakshetri / gist:2934766
Created June 15, 2012 05:10 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version