Skip to content

Instantly share code, notes, and snippets.

View GitEliteNovice's full-sized avatar
:octocat:
Having Fun

Aryan Dhankar GitEliteNovice

:octocat:
Having Fun
View GitHub Profile
@GitEliteNovice
GitEliteNovice / MyPool.java
Created January 14, 2018 07:08
Thread pool Singleton Class
package nation.know.aryan.com.poolofthreads.threadPoolClass;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
@GitEliteNovice
GitEliteNovice / MyRejectedExecutionHandler.java
Created January 14, 2018 07:10
Rejection Execution Handler
package nation.know.aryan.com.poolofthreads.rejectedExecutionHandler;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* Created by dell on 1/14/2018.
*/
@GitEliteNovice
GitEliteNovice / MyRunnable.java
Created January 14, 2018 07:17
Runnable class
package nation.know.aryan.com.poolofthreads.runnable;
import nation.know.aryan.com.poolofthreads.threadPoolClass.MyPool;
/**
* Created by user on 11/1/18.
*/
public class MyRunnable implements Runnable {
MyPool info;
Greedy Knapsack
{
for i=1 to n //step1
{
compute pi/wi; //step2
}
sort objects in non- increasing order p/w; //step3
for i=1 to n //step4
if(m>0 && wi<=m) //step5
Greedy Knapsack
{
for i=1 to n //step1
{
compute pi/wi; //step2
// form 1 to n we have compute above code ---- O(n) (tim taken , since it runs n times)
}
sort objects in non- increasing order p/w; //step3
val pendingIntent: PendingIntent =
Intent(this, ExampleActivity::class.java).let { notificationIntent ->
PendingIntent.getActivity(this, 0, notificationIntent, 0)
}
val notification: Notification = Notification.Builder(this, CHANNEL_DEFAULT_IMPORTANCE)
.setContentTitle(getText(R.string.notification_title))
.setContentText(getText(R.string.notification_message))
.setSmallIcon(R.drawable.icon)
@GitEliteNovice
GitEliteNovice / Webview.java
Last active July 9, 2020 12:05
Get Authentication code for LinkedN
public class NewLinkedInIntegration extends Activity {
/*CONSTANT FOR THE AUTHORIZATION PROCESS*/
/****FILL THIS WITH YOUR INFORMATION*********/
//This is the public api key of our application
private static final String API_KEY = "your client id";
//This is the private api key of our application
private static final String SECRET_KEY = "your secret key";
private void sendGetRequestForEmail(String urlString, String accessToken) throws Exception {
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Bearer " + accessToken);
con.setRequestProperty("cache-control", "no-cache");
con.setRequestProperty("X-Restli-Protocol-Version", "2.0.0");
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuilder jsonString = new StringBuilder();
String line;
public void sendGetRequest(String urlString, String accessToken) throws Exception {
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Authorization", "Bearer " + accessToken);
con.setRequestProperty("cache-control", "no-cache");
con.setRequestProperty("X-Restli-Protocol-Version", "2.0.0");
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
private class PostRequestAsyncTask extends AsyncTask<String, Void, Boolean> {
@Override
protected void onPreExecute() {
pd = ProgressDialog.show(NewLinkedInIntegration.this, "", "Loading", true);
}
@Override
protected Boolean doInBackground(String... urls) {
if (urls.length > 0) {