Skip to content

Instantly share code, notes, and snippets.

View codenirvana's full-sized avatar
[object Object]

Udit Vasu codenirvana

[object Object]
View GitHub Profile
@codenirvana
codenirvana / create-travis-token.sh
Last active September 19, 2020 12:36 — forked from travi/create-travis-token.sh
limit npm token to travis instances
# list of IPs from https://docs.travis-ci.com/user/ip-addresses/
## Linux and Windows
npm token create --cidr=$(echo $(dig +short {nat.gce-us-central1.travisci.net,nat.gce-us-east1.travisci.net}) | sed 's_ _/32,_g')/32
## OSX
npm token create --cidr=$(echo $(dig +short nat.macstadium-us-se-1.travisci.net) | sed 's_ _/32,_g')/32
## ALL
npm token create --cidr=$(echo $(dig +short nat.travisci.net) | sed 's_ _/32,_g')/32
Promise.prototype.safe = function () {
return this.then(data => {
if (data instanceof Error) return [data];
return [null, data];
}).catch(err => [err]);
}
// const [err, result] = await promise.safe();
@codenirvana
codenirvana / proxy.js
Created January 6, 2020 19:44
Crazy Proxy c.h.a.i.n()
const proxy = new Proxy(() => proxy, { get: () => proxy });
// proxy.do().whatever.you.want().to.do()
@codenirvana
codenirvana / a===1 && a===2 && a===3.js
Last active January 6, 2020 19:33
a===1 && a===2 && a===3
this.value = 0; // global, window, or globalThis ¯\_(ツ)_/¯
Object.defineProperty(this, 'a', {
get: () => ++this.value
});
@codenirvana
codenirvana / a==1 && a==2 && a==3.js
Last active January 6, 2020 19:34
a==1 && a==2 && a==3
const a = {
value : 0,
valueOf: () => ++a.value
};

Keybase proof

I hereby claim:

  • I am codenirvana on github.
  • I am codenirvana (https://keybase.io/codenirvana) on keybase.
  • I have a public key ASBP2UHdme1PtmOoDChk0QZvSfTQz65VKT_aSMmkgR0Ojwo

To claim this, I am signing this object:

@codenirvana
codenirvana / rawEcho.js
Created February 25, 2019 02:38
Simple RAW HTTP Echo Server in Node.js
const net = require('net');
net.createServer(function (socket) {
socket.on('data', function (chunk) {
socket.write('HTTP/1.1 200 Ok\r\n');
socket.write('\r\n');
socket.write(chunk.toString());
socket.end();
});
}).listen(3000);
@codenirvana
codenirvana / rawResponse.js
Created August 13, 2018 11:22
Node.js Dump Raw HTTP Response
const http = require('http');
const server = http.createServer();
server.on('connection', (socket) => {
socket.end(`HTTP/1.1 204 No Content
Content-Length: 12
Content-Type: text/plain
Hello World!`);
});
@codenirvana
codenirvana / echo.js
Created August 10, 2018 10:09
Simple HTTP Echo Server in Node.js
require('http')
.createServer((req, res) => req.pipe(res))
.listen(8080);
@codenirvana
codenirvana / Quack & Hack Links.md
Last active February 2, 2016 18:31
DuckDuckGo Global Global Quack & Hack 2 - Quick Links