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 / 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 = []
@valmayaki
valmayaki / launch.json
Created August 29, 2019 00:58
serverless offline debug
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
@valmayaki
valmayaki / memory-calc.js
Created July 25, 2019 08:21
memory calculations
function bytesToSize(bytes) {
if(bytes == 0) return '0 Byte';
var k = 1000;
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
}
@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 <syed@lukonet.com>
* @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 / paystack-component.ts
Last active June 20, 2019 13:03
Custom paystack component
import {
Component,
OnInit,
Output,
Input,
ComponentFactoryResolver,
OnDestroy,
ViewContainerRef, ViewChild, ComponentRef, AfterViewInit, Inject, Optional
} from '@angular/core';
import {PAYSTACK_KEY} from './paystack-key.token';