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 / 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
const pixel = new Image();
pixel.src = '//googlepixel.com/id=12345';
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 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() {
@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()
@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 / 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;