Skip to content

Instantly share code, notes, and snippets.

View jvmvl's full-sized avatar
😜
Hello World

Jamal Chahir jvmvl

😜
Hello World
View GitHub Profile
@jvmvl
jvmvl / allkeys.php
Created March 6, 2020 09:00 — forked from jcefoli/allkeys.php
List All Key/Value Pairs in Redis using the Predis Library. Assumes that Redis is running locally on default port 6379 with no password auth
<?
//Include Predis library. See https://github.com/nrk/predis for more info
require "Predis/Autoloader.php";
//Connect to Redis
Predis\Autoloader::register();
try {
$redis = new Predis\Client();
$redis = new Predis\Client(array(
"scheme" => "tcp",
@jvmvl
jvmvl / output.js
Created October 2, 2019 16:32 — forked from derhuerst/output.js
how fetch a GitHub user's stars
[
{
owner: 'bcoe',
repo: 'top-npm-users',
description: ':star: Generate a list of top npm users by based on monthly downloads.',
language: 'JavaScript',
isFork: false,
stargazers: 27,
watchers: 27
}
@jvmvl
jvmvl / mysql-dump-tables-by-prefix.txt
Created September 21, 2019 11:06 — forked from tofirius/mysql-dump-tables-by-prefix.txt
MySQL dump of tables that begin with a given prefix
mysql database_name -u username -pPassWord -N -e 'show tables like "tableprefix\_%"' | xargs mysqldump database_name --u username -pPassWord > prefixedtable_dump.sql

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost