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
@valmayaki
valmayaki / load_dotenv.sh
Created May 20, 2020 17:32 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@valmayaki
valmayaki / ProfilePage.md
Last active April 21, 2020 17:47
Html Assignment

Create a Profile Page using Html and css

Here is how the profile page should look Profile page

Profile image

Key Value

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 / SSH_Tips.md
Last active April 12, 2020 23:50
SSH Tips

Port forward to MySQL database

ssh -M -S <my-socket-name> -fNT -L localhost:33067:localhost:3306 <user>@<hostname>
  • -f Run in the background before command execution.
  • -N Don’t execute any commands
  • -T Disable pseudo-tty allocation. I don’t know what this means.
@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 / response.php
Created March 14, 2020 14:10
Handling Http Range header in Laravel
<?php
// https://laravel.io/forum/09-23-2014-how-to-support-http-byte-serving-in-file-streams
// Provide a streaming file with support for scrubbing
private function streamFile( $contentType, $path ) {
$fullsize = filesize($path);
$size = $fullsize;
$stream = fopen($path, "r");
$response_code = 200;
$headers = array("Content-type" => $contentType);
@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 / download.php
Created January 7, 2020 12:33
Download files in PHP on the server
<?php
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
static $filesize = null;
switch ($notification_code) {
case STREAM_NOTIFY_RESOLVE:
case STREAM_NOTIFY_AUTH_REQUIRED:
case STREAM_NOTIFY_COMPLETED:
case STREAM_NOTIFY_FAILURE:
@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 = []