Skip to content

Instantly share code, notes, and snippets.

View prashanta's full-sized avatar
🚀

Prashanta Shrestha prashanta

🚀
View GitHub Profile
@prashanta
prashanta / queue.js
Created November 14, 2021 17:03
Prgram to test async.queue usage
/**
* Prgram to test async.queue usage
* - gerenates tasks at the rate of "taskGenRate"
* - tasks are proocessed at the rate of "taskProcessRate"
* - process is paused when queue size reaches "maxQueueSize"
*/
const async = require('async');
let i = 0;
@prashanta
prashanta / kafka-common-commands.md
Last active July 22, 2022 21:31
Apache Kafka - Useful Commands
Action Command
START ZOOKEEPER AND KAFKA BROKER ./bin/kafka-server-start.sh -daemon ./config/server.properties

./bin/zookeeper-server-start.sh --deamon ./config/zookeeper.properties
CREATE NEW TOPIC ./bin/kafka-topics.sh --create --topic test --partitions 3  --bootstrap-server localhost:9092
GET TOPIC INFO ./bin/kafka-topics.sh --list --bootstrap-server localhost:9092 

./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092
GET LIST OF CONSUMER GROUPS ./bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092
GET CONSUMER GROUP INFORMATION (second example is for Azure Event Hub): ./bin/kafka-consumer-groups.bat --bootstrap-server localhost:9092 --group test --describe ./bin/kafka-consumer-groups.sh --command-config config/consumer.properties --bootstrap-server mynamespace.servicebus.windows.net:9093 --describe --grou
@prashanta
prashanta / task.js
Last active May 15, 2020 20:30
Async.Queue usage
/**
* Prgram to test async.queue usage
* - gerenates tasks at the rate of "taskGenRate"
* - tasks are proocessed at the rate of "taskProcessRate"
* - process is paused when queue size reaches "maxQueueSize"
*/
const async = require('async');
let i = 0;
@prashanta
prashanta / .gitignore
Last active July 30, 2017 04:20
Filtered Exception Catching in Bluebird Promise
node_modules
@prashanta
prashanta / reoccurring-git-commands.md
Last active August 3, 2016 04:26
Reoccurring Git Commands

Some reoccurring git commands

  • Graphical git log

    git log --graph --oneline --decorate

  • Difference between local file and remote

    git diff origin/master path/to/file.ext

@prashanta
prashanta / default.js
Last active June 3, 2016 08:00
Reusing ES6 React Component on Server Side (yup, node.js does not support ES6 yet, so this is a hack using Babel)
var express = require('express');
var router = express.Router();
var babel = require("babel-core");
var React = require('react');
// Get ReactDOMServer for server side rendering
var ReactDOMServer = require('react-dom/server');
// Compile code transformed by babel.transformFileSysnc
module._compile(babel.transformFileSync('./public/js/components/header.js').code);
// Save it to a accessible header before moudle.exports gets replaaced
@prashanta
prashanta / collection.md
Last active January 7, 2022 23:20
Collection of shell commands/scripts

Common Linux Commands

Contained here are trival stuffs. Like with all trival stuffs, its inevitably bound to be forgotten.

Description Command
List only directories ls -l | grep ^d
Count number of files & directories ls -l | tail +2 | wc -l
Command prompt coloring__ (Add to ~/.bash_profile) \n Color reference here export PS1="\e[36;1m[\W] \e[0m"
Colorizing terminal (Add to ~/.bash_profile) export CLICOLOR=1 \n export LSCOLORS=gacadxFxCxDxBxegedabagace
@prashanta
prashanta / index.html
Last active August 2, 2016 03:51
Show User Location
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas {
position: absolute;
width: 100%;
@prashanta
prashanta / SerialRelay.ino
Created October 11, 2012 12:05
Data relay between two USARTs of an Arduino
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(10, 11);; // RX, TX
void setup() {
pinMode(10,INPUT);
pinMode(11,OUTPIT);
mySerial.begin(19200);// this connects to the other USART device
Serial.begin(19200); // this one connects to a computer via USB
while (!Serial) {
@prashanta
prashanta / googletalkwindow.js
Created August 16, 2010 05:27
Google Talk on a pop-up window
javascript:(function(){%20window.open('http://talkgadget.google.com/talkgadget/popout','myWindow',%20'status=1,%20height=600,width=400,resizable%20=%200,location=0');%20})();