Skip to content

Instantly share code, notes, and snippets.

@jheys
jheys / example.js
Last active December 16, 2020 14:02
single evaluate call in puppeteer
// there's a bit of ES6 magic at play here - actually, is it even magic at this point?
// anyway...
// instead of calling evaluate for each variable, like this:
const a = page.evaluate(() => document.querySelector('#selectorA').textContent);
const b = page.evaluate(() => document.querySelector('#selectorB').textContent);
const c = page.evaluate(() => document.querySelector('#selectorC').textContent);
// you could evaluate once and return an array of values and deconstruct them into the
// variable names you want. like this:
@jheys
jheys / mcdel
Created July 2, 2014 20:34
Delete memcached item(s) by prefix
#!/bin/bash
HOST=$1
PORT=$2
PREFIX=$3
if [ -z "$HOST" ] || [ -z "$PORT" ] || [ -z "$PREFIX" ]
then
echo "usage: mcdel host port prefix"
else
echo 'stats items' | nc $HOST $PORT | cut -d':' -f2 | uniq | grep -v END | xargs -n1 -I % sh -c "echo \"stats cachedump % 0\" | nc $HOST $PORT" | grep "^ITEM $PREFIX" | sed -E 's/ITEM\ (.*)\ \[.*\]/\1/' | xargs -I % -n1 sh -c "echo 'delete %' | nc $HOST $PORT" | wc -l | xargs -n1 -I % echo "% item(s) deleted"
fi
@jheys
jheys / mcf
Last active August 29, 2015 14:03
MemCached Finder (mcf): finds/lists memcached keys filtered by optional prefix
#!/bin/bash
HOST=$1
if [ "$HOST" = "" ]
then
echo "usage: mcf host [port [prefix]]"
else
PORT=$2
PORT=${PORT:=11211}
PREFIX=$3
@jheys
jheys / install-kettle.sh
Created September 20, 2013 14:11
Installs Pentaho Data Integration (Kettle) CE tools with MS SQL and MySQL connectors/drivers for JDBC
# Download
wget http://hivelocity.dl.sourceforge.net/project/pentaho/Data%20Integration/4.4.0-stable/pdi-ce-4.4.0-stable.tar.gz
wget http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.26.tar.gz
wget http://download.microsoft.com/download/0/2/A/02AAE597-3865-456C-AE7F-613F99F850A8/sqljdbc_4.0.2206.100_enu.tar.gz
# Extract
tar -xvzf pdi-ce-4.4.0-stable.tar.gz
tar -xvzf mysql-connector-java-5.1.26.tar.gz
tar -xvzf sqljdbc_4.0.2206.100_enu.tar.gz