Skip to content

Instantly share code, notes, and snippets.

View Hiweus's full-sized avatar
🏠
Working from home

Andre Alves Leocadio Hiweus

🏠
Working from home
View GitHub Profile

Calc distance

SQL Server function to calc distance between two coordinates

create FUNCTION [dbo].[fncCalcula_Distancia_Coordenada](
                                                   @decLat1Deg DECIMAL(9,6), -- First latitude in degrees.
                                                   @decLon1Deg DECIMAL(9,6), -- First longitude in degrees.
                                                   @decLat2Deg DECIMAL(9,6), -- Second latitude in degrees.

Configure mocha to watch typescript files

When you use mocha with flag --watch on typescript you need to set .mocharc.json file on root folder of project to specify for mocha watch .ts files; Otherwise the terminal will spawn in the first run but will not restart when you save the file.

// .mocharc.json
{
    "extension": [
 "ts"
@Hiweus
Hiweus / multiple-ssh.md
Last active March 25, 2024 03:07
Configure computer to use multiple ssh keys for same service

Configure multiple ssh keys on machine

For this project i will use github as example. I have two keys id_rsa and personal_rsa.

First of all you need to create file ~/.ssh/config. Inside the file put content as follow and edit as your need

# Default configuration (ask for password if there's no key in config file)
Host *
IdentitiesOnly yes

This script below get a path to one video and stream using php, this is possible because the Range header field. If the browser doesn't allow this header the script only drop all video on response.

<?php
  function streamVideo($path) {
      $fileInfo = pathinfo($path);
      header("Content-Disposition: inline; filename=\"{$fileInfo['basename']}\"");
      if(!isset(getallheaders()['Range'])) {
          echo file_get_contents($path);