Skip to content

Instantly share code, notes, and snippets.

View mahidaparth7's full-sized avatar

Parth Mahida mahidaparth7

  • Surat,India
View GitHub Profile
@mahidaparth7
mahidaparth7 / CatchAsync.js
Created September 21, 2023 16:08
CatchAsync
const catchAsync = (fn) => {
return (req, res, next) => {
fn(req, res, next).catch((err) => {
console.error("err", err);
if (err.errors) {
let errorBag = [];
Object.keys(err.errors).forEach((fieldName) => {
errorBag.push({ [fieldName]: err.errors[fieldName] });
});
console.log("err", err);
@mahidaparth7
mahidaparth7 / ApiResponse.js
Created September 21, 2023 16:07
ApiResponse
export default function (req, res, next) {
res.ok = function (data, message) {
const response = {
code: "OK",
message: message || "Operation successfully executed.",
data: data,
};
res.status(200);
res.json(response);
};
#open port
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
git clone --recursive
git pull --recurse-submodules
var request = require("request");
let asyncRequest;
let reqPromise = new Promise(function(resolve, reject) {
//first query
request("http://www.google.com", function(error, response, body) {
console.log("called 1");
if (error) {
reject("hi, this is error");
} else {
//second query that is dependent on first query
@mahidaparth7
mahidaparth7 / nodejs-tcp-example.js
Created December 3, 2019 08:08 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
adb shell input keyevent 82
adb shell input keyevent 82
#wine
sudo apt install wine64
#lightshot - for screenshot
wget http://app.prntscr.com/build/setup-lightshot.exe --no-check-certificate
wine ./setup-lightshot.exe
#winscp
wget https://cdn.winscp.net/files/winscp435setup.exe
wine ./winscp435setup.exe
#pac-vs
wget http://sourceforge.net/projects/pacmanager/files/pac-4.0/pac-4.5.5.5-all.deb
@mahidaparth7
mahidaparth7 / install-postman-ubuntu.txt
Created March 18, 2019 05:10
install-postman-ubuntu
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman