Skip to content

Instantly share code, notes, and snippets.

View virgenherrera's full-sized avatar
💪
Powerizing skills...

Hugo Virgen virgenherrera

💪
Powerizing skills...
  • Guadalajara, Jalisco
  • 17:32 (UTC -06:00)
View GitHub Profile
export function distBetweenCoordinates(point1: number[], point2: number[], precision: number = 4): number {
// function to convert degrees to radians
const rad = (deg) => deg * Math.PI / 180;
// Earth radius in km
const EARTH_RADIUS = 6378.137;
let factor = '1';
for (let i = 1; i < precision; i++) {
factor += '0';
function ObjectId() {
const timestamp = (new Date().getTime() / 1000 | 0).toString(16);
const randomize = () => Math.random() * 16 | 0;
const randStr = 'xxxxxxxxxxxxxxxx'.replace(/x/g, () => randomize().toString(16)).toLowerCase();
return `${timestamp}${randStr}`;
}
interface IStarBucket {
1: string[];
2: string[];
3: string[];
4: string[];
5: string[];
}
export function calcFiveStarRating(ratings: IStarBucket) {
let totalWeight = 0;
@virgenherrera
virgenherrera / function stringWeight
Created September 12, 2017 23:13
this function receives a string, encoding, and decimals; and returns the weight if that string in bytes
function stringWeight(str,encoding,decimals) {
var bytes = Buffer.byteLength( str , encoding || 'utf8' );
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
Sub Descubrir_contraseña()
Dim a As Integer, b As Integer, c As Integer
Dim d As Integer, e As Integer, f As Integer
Dim a1 As Integer, a2 As Integer, a3 As Integer
Dim a4 As Integer, a5 As Integer, a6 As Integer
On Error Resume Next
For a = 65 To 66: For b = 65 To 66: For c = 65 To 66
For d = 65 To 66: For e = 65 To 66: For a1 = 65 To 66
For a2 = 65 To 66: For a3 = 65 To 66: For a4 = 65 To 66
For a5 = 65 To 66: For a6 = 65 To 66: For f = 32 To 126
@virgenherrera
virgenherrera / gitTricks.txt
Created September 6, 2016 21:07
my git workflow, and easy but usefull tricks
#common workflow
clone, make branch, commit, return to origin branch, pull, rebase and push.
#For a list of files to be pushed (between git commit and git push)
git diff --stat --cached origin/master