Skip to content

Instantly share code, notes, and snippets.

View n1lesh's full-sized avatar
🏠
Working from home

Nilesh Singh n1lesh

🏠
Working from home
View GitHub Profile
@n1lesh
n1lesh / NodeHTTPs1.js
Last active October 19, 2019 14:32
HTTPs Server with Node.js and Express
var express = require('express');
var app = express();
var fs = require('fs');
@n1lesh
n1lesh / AndroidManifest.xml
Created June 12, 2017 11:00
Sample Code for Push Notifications (FCM) on Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mynotificationsapp.android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@n1lesh
n1lesh / fcm1.js
Last active May 31, 2023 12:24
Firebase Cloud Messaging with Node.js
'use strict'
const app = require('express')(),
request = require('request'),
mongo = require('mongodb'),
bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: false
@n1lesh
n1lesh / LinearGradientDrawable.java
Last active January 30, 2022 03:57
Android Gradient Toolbar and Statusbar
RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel);
GradientDrawable drawable = new GradientDrawable();
drawable.setColors(new int[] {
Color.parseColor("#FFF6B7"),
Color.parseColor("#F6416C")
});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);
@n1lesh
n1lesh / ButtonSpringEffect.java
Last active June 22, 2017 10:28
Getting spring like effect on Android Buttons with ViewPropertyAnimator
final Button button = (Button) findViewById(R.id.v);
final ViewPropertyAnimator animator = button.animate();
animator.setDuration(200);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button.setEnabled(false);
@n1lesh
n1lesh / SafeBrowsingManifest.xml
Last active August 28, 2022 23:53
Enable Safe Browsing in WebViews - Android O
<manifest>
<application>
. . .
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
. . .
</application>
</manifest>
@n1lesh
n1lesh / SampleCardView.java
Created August 4, 2017 06:47
Android CardView Sample - XML and Java Raw
CardView cardView = (CardView) findViewById(R.id.cardView);
cardView.setUseCompatPadding(true);
cardView.setContentPadding(30, 30, 30, 0);
cardView.setPreventCornerOverlap(true);
cardView.setCardBackgroundColor(Color.WHITE);
cardView.setCardElevation(2.1f);
cardView.setRadius(0);
cardView.setMaxCardElevation(3f);
@n1lesh
n1lesh / AndroidManifest.xml
Created December 18, 2017 08:30
Sample Code for Push Notifications (FCM) on Android - Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mynotificationsapp.android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@n1lesh
n1lesh / InstanceIdService.java
Created December 18, 2017 08:31
Sample Code for Push Notifications (FCM) on Android - Instance ID Service
package com.mynotificationsapp.android;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@n1lesh
n1lesh / MessageReceiver.java
Created December 18, 2017 08:33
Sample Code for Push Notifications (FCM) on Android - Message Receiver
package com.mynotificationsapp.android;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;