Skip to content

Instantly share code, notes, and snippets.

View valmayaki's full-sized avatar
🤠
Happy to be of service to you!

Valentine Ubani Mayaki valmayaki

🤠
Happy to be of service to you!
View GitHub Profile

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

@valmayaki
valmayaki / setting-up-babel-nodemon.md
Created April 1, 2020 18:19 — forked from sam-artuso/setting-up-babel-nodemon.md
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@valmayaki
valmayaki / ffmpeg.md
Created March 12, 2020 16:23 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@valmayaki
valmayaki / testrunner.html
Created November 7, 2019 15:45 — forked from jonnyreeves/testrunner.html
Unit Testing Promises with Sinon.js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
<!-- when.js Promises implementation -->
<script src="https://raw.github.com/cujojs/when/master/when.js"></script>
<!-- Unit testing and mocking framework -->
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
@valmayaki
valmayaki / bucketSort.py
Created August 31, 2019 10:09 — forked from joaofeitoza13/bucketSort.py
Bucket Sort python code.
import random
import math
import timeit
import matplotlib.pyplot as plt
timeBubble = []
timeSelection = []
timeInsertion = []
timeQuick = []
timeMerge = []
@valmayaki
valmayaki / downloadFileChunks.php
Created July 24, 2019 08:47 — forked from irazasyed/downloadFileChunks.php
PHP: File downloader function - Downloading files in chunks.
<?php
/**
* Download helper to download files in chunks and save it.
*
* @author Syed I.R <[email protected]>
* @link https://github.com/irazasyed
*
* @param string $srcName Source Path/URL to the file you want to download
* @param string $dstName Destination Path to save your file
* @param integer $chunkSize (Optional) How many bytes to download per chunk (In MB). Defaults to 1 MB.
@valmayaki
valmayaki / docker-php_apache_modrewrite.sh
Created March 25, 2019 05:27 — forked from iamsortiz/docker-php_apache_modrewrite.sh
Docker php apache modrewrite bash utils
# Convenience bash utils to handle docker: php + apache + modrewrite
# * related issue: https://github.com/docker-library/php/issues/179#issuecomment-234594522
#
# Usage:
# * Download the file
# * In your "bash file"
# * On debian based systems use: ~/.bashrc
# * On Mac use: ~/.bash_profile
# * Include the line: source PATH_TO_THE_DOWNLOADED_FILE
# * Or just copy and paste the contents of this file
@valmayaki
valmayaki / AttachJwtToken.php
Created January 25, 2019 14:17 — forked from whoisryosuke/AttachJwtToken.php
Laravel - Testing - Base class to extend basic API tests
<?php
namespace Tests\Traits;
use KushyApi\User;
trait AttachJwtToken
{
/**
* @var User
@valmayaki
valmayaki / AttachJwtToken.php
Created January 21, 2019 16:09 — forked from jgrossi/AttachJwtToken.php
AttachJwtToken.php
<?php
namespace Tests\Concerns;
use App\Models\User;
use Tymon\JWTAuth\Facades\JWTAuth;
trait AttachJwtToken
{
/**
@valmayaki
valmayaki / computeHeading.js
Created November 5, 2018 14:26 — forked from jesty/computeHeading.js
Compute heading
/*
* A heading is defined in degrees from true north, where headings are measured clockwise from true north (0 degrees).
* The parameter for this function are two array that identifies a geo point with latitude at position 0 and longitude
* at position 1.
* This function is similar to https://developers.google.com/maps/documentation/javascript/geometry. I developed because
* I need it on Meteor server side.
* The result is a value between -180 and 180.
*/
var computeHeading = function (start, end){
var lat1 = start[0]*Math.PI/180;