Skip to content

Instantly share code, notes, and snippets.

View prameshbajra's full-sized avatar
💻
Let's talk tech.

Pramesh Bajracharya prameshbajra

💻
Let's talk tech.
View GitHub Profile
@prameshbajra
prameshbajra / available_ip.sh
Created January 7, 2020 14:07
Gives the list of IPs that are Busy or Open.
#!/bin/sh
# Uncomment for debugging
#set -x
pingf(){
if ping -w 2 -q -c 1 192.168.1."$1" > /dev/null ;
then
printf "IP %s is up\n" 192.168.1."$1"
else
printf "IP %s is open\n" 192.168.1."$1"
fi
@prameshbajra
prameshbajra / Flask_JWT_Auth
Created February 13, 2019 10:45
Flask API JWT Authentication without database.
from flask import Flask
from flask_jwt import JWT, jwt_required, current_identity
from werkzeug.security import safe_str_cmp
class User(object):
def __init__(self, id, username, password):
self.id = id
self.username = username
self.password = password
@prameshbajra
prameshbajra / chat.js
Created June 8, 2018 13:22
Tiny api communicator that acts as chat messenger. Made in less than 15 mins. Work locally only.
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork();
cluster.on('exit', function(worker, code, signal) {
cluster.fork();
});
}
@prameshbajra
prameshbajra / shareNode.js
Last active June 8, 2018 12:36
Share files locally in very high speed.
const cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork();
cluster.on('exit', function(worker, code, signal) {
cluster.fork();
});
}
@prameshbajra
prameshbajra / Diamond.java
Created June 7, 2018 13:20
Diamond Pattern in java.
package com.demo.advjava;
public class StarsPattern {
public static void main(String[] args) {
printStars90(10);
printStarsRev(10);
// printStarsRev(10);
printStars(10);
}
@prameshbajra
prameshbajra / AdjMatGraph.java
Created June 7, 2018 08:59
Adjaceny Matric Implementation for Graph in JAVA.
package com.demo.advjava;
public class GraphImplementationAdjMat {
int[][] graph;
public GraphImplementationAdjMat(int vertices) {
graph = new int[vertices][vertices];
}
@prameshbajra
prameshbajra / TypeFun.java
Created June 7, 2018 06:44
Open a preferred application and start typing automatically.
package com.demo.advjava;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
public class NotepadFun {
public static void main(String[] args) throws IOException, InterruptedException, AWTException {
Runtime.getRuntime().exec("gedit");
@prameshbajra
prameshbajra / N queens Solution.java
Last active June 6, 2018 13:38
NQueens - My solution
package com.demo.advjava;
public class NQueensTesting {
int boardSize = 8;
int[][] board = new int[boardSize][boardSize];
public void populateBoard() {
int i, j;
for (i = 0; i < boardSize; i++)
@prameshbajra
prameshbajra / circularlinkedlist.java
Created June 5, 2018 13:43
By - Pramesh Bajracharya
package com.demo.advjava;
public class CircularLinkedList {
Node head;
class Node {
int data;
Node next;
@prameshbajra
prameshbajra / circularlinkedlist.c
Created June 5, 2018 13:41
By - Pavan Yekabote
#include<stdio.h>
#include<stdlib.h>
struct nde {
int data;
struct nde *link;
};
typedef struct nde* Node;