Skip to content

Instantly share code, notes, and snippets.

View nikitaeverywhere's full-sized avatar
🇺🇦
Just build it!

Nikita Savchenko nikitaeverywhere

🇺🇦
Just build it!
View GitHub Profile
// Load testing of http-proxy node library.
// $ docker run -it --rm bash:4.4
// $ docker run -it --rm node:12-alpine sh
// # mkdir -p /test && cd /test && wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-amd64.tar.gz && tar -xvf vegeta-12.8.3-linux-amd64.tar.gz
// # wget -O - https://gist.githubusercontent.com/ZitRos/c0d0ea80c0de4d018121c80c5d2c3653/raw/node-http-proxy-load-test.js > index.js && npm install http-proxy
// # node index.js & sleep 0.5 && echo 'GET http://localhost/favicon.ico' | ./vegeta attack -rate 15 -duration 5s | ./vegeta report -every 1s && pkill node
const http = require('http');
const httpProxy = require('http-proxy');
=1173002295&_v=j83&z=1887421163
2020-06-21T20:41:02.409Z proxied: stats.g.doubleclick.net/r/collect?v=1&aip=1&t=dc&_r=3&tid=UA-55446531-20&cid=9257118.1592772062&jid=779824401&_gid=218034169.1592772062&gjid=52807921&_v=j83&z=1610133504
2020-06-21T20:41:03.025Z proxied: www.googletagmanager.com/gtag/js?id=UA-55446531-20
2020-06-21T20:41:03.096Z proxied: www.googletagmanager.com/gtag/js?id=UA-55446531-20
2020-06-21T20:41:03.184Z proxied: www.googletagmanager.com/gtag/js?id=UA-55446531-20
2020-06-21T20:41:03.425Z proxied: www.google-analytics.com/r/collect?v=1&_v=j83&a=1390828066&t=pageview&_s=1&dl=https%3A%2F%2Fwww.freecodecamp.org%2Fnews%2Fhow-to-delete-a-git-branch-both-locally-and-remotely%2F&dr=https%3A%2F%2Fwww.google.com%2F&ul=en-us&de=UTF-8&dt=How%20to%20Delete%20a%20Git%20Branch%20Both%20Locally%20and%20Remotely&sd=30-bit&sr=1680x1050&vp=918x948&je=0&_u=AACAAUAB~&jid=953499377&gjid=1340825163&cid=1651878937.1592524654&tid=UA-55446531-20&_gid=1139165038.1592753739&_r=1&gtm=2ou6a0&z=1634154742&uip=108.26.
@nikitaeverywhere
nikitaeverywhere / TEST.sol
Last active May 4, 2018 17:29
Can't be verified at Etherscan https://ropsten.etherscan.io/address/0x746612a6d4dcadbff55619bedeba403c0c252361#code (optimization with runs = 200 were used, both in Truffle 0.4.23 and remix with compiler version 0.4.23+commit.124ca40d.Emscripten.clang). [SOLVED] https://ethereum.stackexchange.com/a/47572/22038
pragma solidity 0.4.23;
contract TEST {
string public someVal;
string public someVal2;
bytes32 public signature1 = keccak256(
"address TEST TEST TEST TEST",
"address TEST TEST TEST TEST TEST TEST",
@nikitaeverywhere
nikitaeverywhere / cloneNodeDeepWithStyles.js
Created May 13, 2017 14:27
Deep node clone node with styles cloning
function deepCloneWithStyles (node) {
const style = window.getComputedStyle(document.body, null);
const clone = node.cloneNode(false);
if (clone.style && style.cssText)
clone.style.cssText = style.cssText;
for (let child of node.childNodes)
clone.appendChild(deepClone(child));
return clone;
}
/**
* Just a piece of code to start.
*/
const host = "127.0.0.1:57772";
let ws = new WebSocket(`ws://${ host }/csp/user/WebCourse.ChatWebSocket.cls`);
ws.addEventListener(`open`, () => {
console.log(`We are connected to the chat!`);
});
/// Original: https://github.com/eduard93/Utils/blob/master/Utils/REST.cls.xml
Class Utils.REST Extends %CSP.REST
{
XData UrlMap
{
<Routes>
<Route Url="/file" Method="GET" Call="GET"/>
</Routes>
}
@nikitaeverywhere
nikitaeverywhere / semCompare.js
Created June 28, 2016 11:08
JavaScript: compare semantic versions
/**
* Semantic versioning versions compare.
* @param {string} high
* @param {string} low
* @returns {boolean}
* @author ZitRo (zitros.lab@gmail.com)
* @license MIT http://www.opensource.org/licenses/mit-license.php
*/
function versionGT (high, low) {
let v1 = high.split(/[\-\.]/g),
@nikitaeverywhere
nikitaeverywhere / MyPackage.xml
Last active March 14, 2016 22:51
Перед вами - пример веб-приложения Caché, которое устанавливает себя самостоятельно после импорта XML-файла. Сохраните архив, нажав вверху на "Download ZIP", разархивируйте и импортируйте его в Caché. Затем, откройте http://localhost:[port]/myWebApp/ (не забудьте добавить косую черту в конце!) и убедитесь, что приложение работает.
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.2 (Build 590U)" ts="2016-03-15 00:40:16">
<Class name="MyPackage.Installer">
<CompileAfter>MyPackage.REST</CompileAfter>
<Super>%Projection.AbstractProjection</Super>
<TimeChanged>63992,1953.207424</TimeChanged>
<TimeCreated>63992,1916.587195</TimeCreated>
<Parameter name="WebAppName">
<Type>%String</Type>
@nikitaeverywhere
nikitaeverywhere / XData-UrlMap.xml
Last active January 9, 2016 15:46
Implementation-very-basic-draft
<Routes>
<!-- Self-documenting links variant: allow <Route> tag to nest additional info -->
<Route Url="/posts" Method="GET" Call="ShowPosts">
<!-- One of many variants, most applicable for Caché XData scheme on my opinion -->
<!-- Nested <Link>s tell what we can do with the current element -->
<Link rel="add" method="POST" href="/posts"/>
<Link rel="next" method="POST" href="/posts/:page"/>
<!-- Nested <LinkGroup>s tell what we can do with the content on the page -->
<LinkGroup name="post">
/**
* Code snippet for students ^^
* Tarnavsky used this function to find t^-1 from prime number t and m.
* Usage: var tMinusOne = getRevT(m, t);
* Test case 1: getRevT(121, 5) === 97
* Test case 2: getRevT(9, 7) === 13
*/
function getRevT (m, t) {
function stage (a, b) {
var r = a % b, q = Math.floor(a/b);