Skip to content

Instantly share code, notes, and snippets.

Avatar

Deepak Koirala deepakkoirala

View GitHub Profile
@deepakkoirala
deepakkoirala / upnp.js
Created May 12, 2020 — forked from acacio/upnp.js
UPNP Port Forwarding for node.js
View upnp.js
/* node UPNP port forwarding PoC
This is a simple way to forward ports on NAT routers with UPNP.
This is a not-for-production hack that I found useful when testing apps
on my home network behind ny NAT router.
-satori
usage:
@deepakkoirala
deepakkoirala / Procfile
Created Jan 18, 2020 — forked from jordansissel/Procfile
Jenkins on Heroku
View Procfile
# Only listen on http; disable ajp and https
web: java -jar jenkins.war --httpPort=$PORT --ajp13Port=-1 --httpsPort=-1
@deepakkoirala
deepakkoirala / remove-rubber-band-web-apps-ios
Created Jan 3, 2020 — forked from amolk/remove-rubber-band-web-apps-ios
Remove rubberband scrolling from web apps on mobile safari (iOS)
View remove-rubber-band-web-apps-ios
<!DOCTYPE html>
<html>
<head>
<title>Remove rubberband scrolling from web apps on mobile safari (iOS)</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
html, body {margin: 0; padding: 0; overflow: hidden}
@deepakkoirala
deepakkoirala / index.html
Created Sep 11, 2019 — forked from umidjons/index.html
Upload File using jQuery.ajax() with progress support
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload File using jQuery.ajax() with progress support</title>
</head>
<body>
<input type="file" name="file" id="sel-file"/>
View udp-client-server-nodejs.md

UDP Client/Server example

File server.js:

'use strict';

var dgram = require('dgram');
var server = dgram.createSocket('udp4');

const PORT = 3000;
@deepakkoirala
deepakkoirala / extend-eventemitter.md
Created Sep 11, 2019 — forked from umidjons/extend-eventemitter.md
Extending EventEmitter example
View extend-eventemitter.md

Extending EventEmitter example

"use strict";

var EventEmitter = require('events').EventEmitter;

class MyClass extends EventEmitter {
    /**
     * Create MyClass instance
@deepakkoirala
deepakkoirala / gist:7fc74fabee11b5b3c4382312a50db479
Created Sep 7, 2019 — forked from corvax19/gist:4275922
Simple text encryption/decryption with openssl
View gist:7fc74fabee11b5b3c4382312a50db479
echo -n "That's the text"|openssl enc -e -aes-256-cbc -a
Encrypt with interactive password. Encrypted message is base64-encoded afterwards.
echo -n "That's the text"|openssl enc -e -aes-256-cbc -a -k "MySuperPassword"
Encrypt with specified password. Encrypted message is base64-encoded afterwards.
echo "GVkYiq1b4M/8ZansBC3Jwx/UtGZzlxJPpygyC"|openssl base64 -d|openssl enc -d -aes-256-cbc
Base-64 decode and decrypt message with interactive password.
echo "GVkYiq1b4M/8ZansBC3Jwx/UtGZzlxJPpygyC"|openssl base64 -d|openssl enc -d -aes-256-cbc -k "MySuperPassword"
@deepakkoirala
deepakkoirala / nodejs-tcp-example.js
Created Sep 1, 2019 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
View nodejs-tcp-example.js
/*
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');
@deepakkoirala
deepakkoirala / tcpproxy.js
Created Aug 31, 2019 — forked from kfox/tcpproxy.js
A basic TCP proxy written in node.js
View tcpproxy.js
var net = require("net");
process.on("uncaughtException", function(error) {
console.error(error);
});
if (process.argv.length != 5) {
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]);
process.exit();
}
@deepakkoirala
deepakkoirala / README.md
Created Aug 31, 2019 — forked from anhldbk/README.md
TLS client & server in NodeJS
View README.md

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation