Skip to content

Instantly share code, notes, and snippets.

View nitink133's full-sized avatar

Nitin Khanna nitink133

View GitHub Profile
@nitink133
nitink133 / PreferenceManager.java
Created September 25, 2018 15:10
Shared Prefrence Android
package in.blackpaper.benitinhere.data.prefs;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
public class PreferencesManager {
private final static String TAG = PreferencesManager.class.getSimpleName();
// private static PreferencesManager instance;
private static SharedPreferences pref;
@nitink133
nitink133 / permissions.java
Created June 26, 2018 16:24
Android camera and gallery permissions
private void selectImage() {
try {
PackageManager pm = getPackageManager();
int hasPerm = pm.checkPermission(Manifest.permission.CAMERA, getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
final CharSequence[] options = {"Take Photo", "Choose From Gallery", "Cancel"};
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.chooseimage_alertdialog_l, null);
@nitink133
nitink133 / permissions.java
Created June 26, 2018 16:24
Android camera and gallery permissions
private void selectImage() {
try {
PackageManager pm = getPackageManager();
int hasPerm = pm.checkPermission(Manifest.permission.CAMERA, getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
final CharSequence[] options = {"Take Photo", "Choose From Gallery", "Cancel"};
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.chooseimage_alertdialog_l, null);
@nitink133
nitink133 / Android dropdown
Created June 26, 2018 16:22
Android dropdown layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/alert_title"
android:layout_width="match_parent"
android:layout_height="0dp"
@nitink133
nitink133 / Datacrawler.py
Created April 19, 2018 06:01
Data Crawler in python
import urllib2,sys
orig_stdout = sys.stdout
f = open('E:/Documents/sample.html', 'w')
sys.stdout = f
response=urllib2.urlopen("https://cracxpro.com/microsoft-office-2013-product-key-generator/")
source=response.read()
print source
@nitink133
nitink133 / maven.txt
Created April 15, 2018 11:27
Work with Apache maven in visual studio code
//Run the following command
mvn archetype:generate
// -DgroupId=..........
// -DartifactId=.........
// -DarchetypeArtifactId=maven-archetype-quickstart
// -DinteractiveMode=false
@nitink133
nitink133 / launch.json
Created April 15, 2018 11:24
launch.json File for java
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch)-App<com.blackpaper.topdf>",
"request": "launch",
@nitink133
nitink133 / Custom_bashrc.sh
Created April 14, 2018 15:33
Custom_bashrc.sh is a custom bashrc file for Ubuntu.
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@nitink133
nitink133 / Screenshots.java
Last active April 14, 2018 15:14
Automatic Screenshots capturing tool for android
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
class Screenshots {
public static void main(String args[]) {
BufferedReader bufferedReader = null;
Scanner scanner=new Scanner(System.in);
@nitink133
nitink133 / Screenshots.py
Created April 14, 2018 07:18
Screenshots.py is an python script for taking screenshots of android mobile using system and save these in system
import os
def Screenshot(n):
pageno=1
for pageno in range(pageno,n):
print ("Wait...")
os.system("adb exec-out screencap -p > " +str(pageno)+".png")
os.system("adb shell input swipe 300 700 50 700")
Screenshot(8)