Skip to content

Instantly share code, notes, and snippets.

View nieldeokar's full-sized avatar

Nilesh Deokar nieldeokar

View GitHub Profile
@nieldeokar
nieldeokar / Boilerplate.md
Last active October 18, 2024 04:12
Boilerplate code snippets.

Boilerplate

contains common code snippets.

Stack

val stack = ArrayDeque<Int>()

stack.addFirst(10) // push to top
val topElement = stack.first() // peek top 
@nieldeokar
nieldeokar / data.json
Last active July 22, 2020 23:33
Take Home Projects - Show National Contiguity with a Force Directed Graph
{
"nodes": [
{ "country": "East Timor", "code": "tl" },
{ "country": "Canada", "code": "ca" },
{ "country": "Turkmenistan", "code": "tm" },
{ "country": "United States of America", "code": "us" },
{ "country": "Lithuania", "code": "lt" },
{ "country": "Cambodia", "code": "kh" },
{ "country": "Ethiopia", "code": "et" },
{ "country": "Swaziland", "code": "sz" },
@nieldeokar
nieldeokar / Apache_Server.c
Last active August 13, 2021 03:22
Simple Apache server to identify difference between socket and port
/*
* @author : Nilesh Deokar/ @nieldeokar
* instructions :
* 1. compile using 'gcc -Wall -o apache Apache_Server.c'
* 2. run ./apache
*/
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
python -m SimpleHTTPServer 8080
@nieldeokar
nieldeokar / ContinueVideoRecorder.java
Last active December 9, 2019 05:41
Android has default filesize limit of 4GB while recording video. To overcome it use this build method.
/*
* Created by Nilesh Deokar<[email protected]> on 18/4/19 2:43 PM
*/
package me.umoove.busCounterApp.models;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
@nieldeokar
nieldeokar / GetAlbumListFromContentProvider.kt
Created March 6, 2019 17:23
Fetches list of image and video Albums using content provider along with path to thumbnail of an album.
package droidninja.filepicker
import android.content.ContentResolver
import android.provider.MediaStore
import android.util.Log
/*
~ Nilesh Deokar @nieldeokar on 03/06/19 9:57 AM
*/
@nieldeokar
nieldeokar / AudioRecordThread.java
Last active October 20, 2024 04:43
Recording an Audio with .aac extension using AudioRecord android.
package com.nieldeokar.whatsappaudiorecorder.recorder;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.os.Build;
import android.util.Log;
@nieldeokar
nieldeokar / SetBitPosition.java
Last active June 2, 2018 06:53
Demonstration of how to set specific bit to 1
int myOriginalValue = 0b0010;
// STEP 1 : 0b0001 << 3 = 0b1000;
// STEP 2 : OR 0b0010; originalValue
// --------------
// RESULT : 0b1010; // 3rd bit is set to true
// Formula for setting a bit :
// myOriginalValue = myOriginalValue | (1 << position);
@nieldeokar
nieldeokar / GetAppUpdateAvailable.java
Last active May 30, 2018 13:36
Used for storing multiple boolean values into one int variable. This snippet checks the bit values set in SetAppUpdateAvailable.java
public class GetAppUpdateAvailable {
private int mUpdateValue = 0b0010;
private static final int UPDATE_AVAILABLE = 1;
private static final int UPDATE_COMPULSORY = 2;
public void getUpdateAvailable(){
boolean result = false;
result = (mUpdateValue & (1 << UPDATE_AVAILABLE)) != 0;
@nieldeokar
nieldeokar / SetAppUpdateAvailable.java
Last active May 30, 2018 13:30
Used for storing multiple boolean values into one int variable.
public class SetAppUpdateAvailable {
private int mUpdateValue = 0;
private static final int UPDATE_AVAILABLE = 1;
private static final int UPDATE_COMPULSORY = 2;
public void setUpdateAvailable(){
mUpdateValue = mUpdateValue | (1 << UPDATE_AVAILABLE);