Skip to content

Instantly share code, notes, and snippets.


ndvb ndvbd

  • Self
View GitHub Profile
ndvbd /
Created June 14, 2021 12:38
Process multiple google chrome debugger tools code coverage jsons in ordet to extract effective source
import json
import re
# code_coverage_filename =
# Will merge all this files
code_coverage_filenames = ['Coverage-20210613T181747.json', 'Coverage-20210613T1817427.json']
specific_file_url = 'https://localhost/bootstrap.min.self.css?body=1'
View Turn off all event listeners
// 10, 11 are the ones -> keydown, keypress
var toRun = new Array(46);
for (var i = 0; i < toRun.length; ++i) { toRun[i] = true; }
function setupListeners(from, to) {
'use strict';
window.addEventListener('error', function (e) {e.preventDefault();e.stopPropagation();}, false);
let handlers = ['copy', 'cut', 'paste', 'beforeunload', 'blur', 'change', 'click', 'contextmenu', 'dblclick', 'focus', 'keydown', 'keypress', 'keyup', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'selectstart',
ndvbd / event-listeners.js
Created June 9, 2018 13:34
Get all event listeners on the page in Google Chrome
View event-listeners.js
// Taken from
var items =
).map(function(element) {
var listeners = getEventListeners(element);
return {
element: element,
listeners: Object.keys(listeners).map(function(k) {
return { event: k, listeners: listeners[k] };
ndvbd / gist:86cd48490b98a27b9a1e5636bba614e2
Created May 4, 2018 08:48
Search everything in a javascript object
View gist:86cd48490b98a27b9a1e5636bba614e2
// Invoke with prefixpath = '', stackdepth = 0, maxdepth = 5
function searchObject(obj, textToSearch, prefixpath, stackdepth, maxdepth){
if (stackdepth >= maxdepth) return;
for (var key in obj) {
try {
if (obj.hasOwnProperty(key)) {
if (key.includes(textToSearch)) {
console.log(prefixpath + "/" + key + " key is: " + (typeof key) + " " + key);
ndvbd / simple_jmeter_get_script.jmx
Created March 12, 2018 10:13
Simple JMeter Concurrent Get Script
View simple_jmeter_get_script.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.0" jmeter="4.0 r1823414">
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
ndvbd /
Created March 10, 2018 21:14
Running Rails Rake task from any user in any folder, by detecting the RVM environment
# By default, passenger will run your app as the user who owns the config/environment.rb or file:
RAILS_USER=$(stat -c '%U' /YOUR_PATH_HERE/environment.rb)
echo "Detected rails user: $RAILS_USER"
sudo -H -u $RAILS_USER bash -c 'RAILS_USER=$USER; echo "I am $USER, with uid $UID" ; echo "whoamI: $(whoami)" ; echo "Running rvm script: /home/$RAILS_USER/.rvm/scripts/rvm" ; source /home/$RAILS_USER/.rvm/scripts/rvm ; ENV_FILE=`rvm env --path` ; echo $ENV_FILE ; source $ENV_FILE ; cd /YOUR_PATH_HERE/lib/tasks ; rake XXX:YYY RAILS_ENV=production'
ndvbd / wrapWordSegmentWithElement
Created March 7, 2018 10:52
wrapWordSegmentWithElement | Parse the text out of a DOM element, and wrap a specific part of the text with a supplied wrapper element
View wrapWordSegmentWithElement
* This wraps the extracted text segment with a parent wrapper element.
* If the desired text segement is spread around few nodes, than it will wrap
* EACH one of the nodes with the same parent wrapper.
* As always, the startPosition is inclusive and the endPosition is exclusive
* rootNode - must be a DOM element (not a jquery element)
function wrapWordSegmentWithElement(rootNode, startPosition, endPosition, emptyWrapperElement){
var n, text='', walk=document.createTreeWalker(rootNode, NodeFilter.SHOW_TEXT, null, false);
while (n = walk.nextNode()) {
ndvbd / ThrottledExecutor
Created March 4, 2018 13:44
ThrottledExecutor | Throttling functions invocations, and allowing only recent invocation to be made. | Javascript
View ThrottledExecutor
// We want to define a throttledExecutor an object that constructs with a number, which is delay in seconds
// The object has one method: invokeThrottled, that accepts a function.
// The object remembers the last invocation time of the function (any function) - only one number to remember.
// If a function wasn't executed during the last 2 seconds, execute immediately.
// Otherwise, wait until 2 seconds will pass and execute the function
// If during the wait a new invocation arrived, forget about the old pending invocation (only remember the newest).
class ThrottledExecutor{
this.delayInSeconds = delayInSeconds;
ndvbd / main.cpp
Last active January 30, 2018 09:05
NadavWatch - View a sequence of PNG files in a directory, allow zoom, pixel values and more.
View main.cpp
// NadavWatch
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
ndvbd / StopWatch
Last active October 24, 2017 08:27
CPP StopWatch
View StopWatch
// Written by Nadav Benedek 2017
class StopWatch {
double accumulatedTimeSeconds = 0;
double startTime = 0;
State state;