Skip to content

Instantly share code, notes, and snippets.

View regevbr's full-sized avatar
👨‍💻
Coding...

Regev Brody regevbr

👨‍💻
Coding...
View GitHub Profile
@regevbr
regevbr / proxy-chain.js
Last active January 17, 2023 01:59
node-http-proxy proxy chain with connect method implemented (+ bonus auth handling)
"use strict";
const http = require('http');
const request = http.request;
const net = require('net');
const httpProxy = require('http-proxy');
let auth = "secret-string";
auth = new Buffer(auth).toString('base64');
auth = "Basic " + auth;
@regevbr
regevbr / .gitlab-ci.yml
Last active April 12, 2018 07:32
gitlab ci push changes to protected branch using node.js
grunt:
only:
- master
script:
- 'git checkout -b CI${CI_JOB_ID}'
#make changes on local repo
- 'git add . || true'
- 'git commit -a -m "[ci skip] build" || true'
- 'git push https://<username>:<token>@gitlab.com/<team>/<project>.git HEAD:CI${CI_JOB_ID} || true'
- 'node ./mergeBranch.js CI${CI_JOB_ID}'
@regevbr
regevbr / puppeteerIncognito.js
Last active February 4, 2022 21:45
How to open "incognito" context in puppeteer
"use strict";
const Promise = require('bluebird');
const Page = require('puppeteer/node6/lib/Page');
function newPageWithNewContext(browser) {
let browserContextId;
let targetId;
let target;
return Promise.resolve()
const createElementBackup = document.createElement;
function myCreateElement(tagName: string, options?: ElementCreationOptions): HTMLElement {
const scriptElt = createElementBackup.call(document, tagName, options);
if (tagName.toLowerCase() !== 'script') {
return scriptElt;
}
const originalSetAttribute = scriptElt.setAttribute.bind(scriptElt);
Object.defineProperties(scriptElt, {
'src': {
get() {
const scriptElement = document.createElement('script');
scriptElement.setAttribute('src','//s7.addthis.com/js/300/addthis_widget.js');
const headElement = document.getElementsByTagName('head')[0];
head.appendChild(scriptElement);
const pixel = new Image();
pixel.src = '//googlepixel.com/id=12345';
@regevbr
regevbr / sqsHelloWorld.js
Last active May 18, 2019 10:39
SQS "hello world"
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
var awsConfig = {
accessKeyId: '<accessKeyId>',
secretAccessKey: '<secretAccessKey>',
region: '<region>'
};
AWS.config.update(awsConfig);
// Create an SQS service object
@regevbr
regevbr / squissHelloWorld.ts
Last active May 18, 2019 10:33
squiss-ts hello world
import {Squiss, Message} from 'squiss-ts';
const awsConfig = {
accessKeyId: '<accessKeyId>',
secretAccessKey: '<secretAccessKey>',
region: '<region>',
};
const squiss = new Squiss({
awsConfig,
@regevbr
regevbr / _scaffoldGetProp.ts
Last active April 22, 2024 13:52
scaffold type safe get function up to a desired order
'use strict';
// tslint:disable:max-line-length
// based on https://www.reddit.com/r/typescript/comments/aynx0o/safe_deep_property_access_in_typescript
import * as fs from 'fs';
const method = 'getProp';
const TAB = ` `;
@regevbr
regevbr / textEmailsUpdater.ts
Last active July 28, 2019 21:29
mautic auto generate email text version
'use strict';
import * as textVersion from 'html-to-text';
import * as mysql from 'mysql';
import * as _ from 'underscore';
const connection = mysql.createConnection({
host: '<host>',
user: '<user>',
password: '<password>',
database: 'mautic',