Skip to content

Instantly share code, notes, and snippets.

View athulantonynp's full-sized avatar
🎯
Focusing

Athul Antony N.P athulantonynp

🎯
Focusing
View GitHub Profile
@athulantonynp
athulantonynp / node_nginx_ssl.md
Created February 11, 2021 13:44 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
@athulantonynp
athulantonynp / PhonecallReceiver.java
Created July 17, 2018 11:44 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@athulantonynp
athulantonynp / gcm-high-prio.sh
Created June 7, 2018 07:28 — forked from sebastianbenz/gcm-high-prio.sh
Send high priority GCM messages via curl (Android Doze mode & App Standby testing)
curl -X POST \
-H "Authorization: key= YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR-GCM-REGISTRATION-ID"
],
"data": {
"message": "Hello Message"
},
@athulantonynp
athulantonynp / ParallelWork.java
Created May 10, 2018 13:32
WorkManagerParallel
//For sequential work ordering.
WorkManager.getInstance()
.beginWith(work1)
.then(work2)
.then(work3)
.enqueue();
WorkManager.getInstance()
// First, all 1 tasks in parallel
.beginWith(work1, workA12, work13)
//Defining the constraints
Constraints myConstraints = new Constraints.Builder()
.setRequiresDeviceIdle(true)
.setRequiresCharging(true)
.build();
//Setting the constraints
myWork.setConstraints(myConstraints)
@athulantonynp
athulantonynp / OneTimWorkRequest.java
Last active July 4, 2018 07:19
OneTimeWorkRequest
//For single execution tasks
OneTimeWorkRequest myWork =
new OneTimeWorkRequest.Builder(MyWorker.class)
.build();
WorkManager.getInstance().enqueue(myWork);
//For recurring tasks
PeriodicWorkRequest.Builder myWorkBuilder =
new PeriodicWorkRequest.Builder(MyWorker.class, 12,
TimeUnit.HOURS);
@athulantonynp
athulantonynp / .java
Last active May 10, 2018 12:22
WorkManager-Sample
public class MyWorker extends Worker {
@Override
public Worker.WorkerResult int doWork() {
if(myBackgroundWork()){
return WorkerResult.SUCCESS;
}else{
@athulantonynp
athulantonynp / proguard.txt
Created April 23, 2018 05:23
Default proguard configs
-keepclassmembers class ** {
public void on*(***);
}
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
-keepclassmembernames class * {
app.post('/hello', (req, res) => {
console.log('Got the call here');
return res.status(200).send("{ \"message\":Hello {req.body.user}}");
});
exports.api=functions.https.onRequest(app);