Skip to content

Instantly share code, notes, and snippets.

View raco's full-sized avatar
🎸
Blues

Renato Centeno raco

🎸
Blues
View GitHub Profile
@raco
raco / only-number.directive.ts
Created May 15, 2024 23:29
Pipe for type only numbers on inputs text
import {
Directive,
ElementRef,
forwardRef,
HostListener,
Renderer2,
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
@Directive({
@raco
raco / http.interceptor.ts
Last active November 28, 2023 17:08
Interceptor + Provider, transform Angular http to Capacitor's http, so if web uses Angular http else Capacitor's http
import { Injectable, Provider } from '@angular/core';
import {
HTTP_INTERCEPTORS,
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpHeaders,
HttpInterceptor,
HttpParams,
HttpRequest,
@raco
raco / index.html
Created December 7, 2021 04:31 — forked from timothycarambat/index.html
Easy Web3 Meta Mask Login - static HTML and Vanilla JS
<html>
<head>
<title>Web3 Metamask Login</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="flex w-screen h-screen justify-center items-center">
<div class="flex-col space-y-2 justify-center items-center">
<button id='loginButton' onclick="" class="mx-auto rounded-md p-2 bg-purple-500 text-white">
@raco
raco / laravel_must_packages.bash
Last active March 20, 2020 09:47
Usefull packages for laravel 6
# Language support for dates ESPAÑOL
# https://github.com/jenssegers/date
composer require jenssegers/date
# Debug bar
# https://github.com/barryvdh/laravel-debugbar
composer require barryvdh/laravel-debugbar --dev
# Populate factories from models
# https://github.com/coderello/laravel-populated-factory
@raco
raco / format_date.js
Created November 14, 2019 20:21
Format date dd mm yyyy for dummies
formatDate(_date: Date, separator = '/') {
const day = _date.getDate();
const month = _date.getMonth() + 1;
const year = _date.getFullYear();
if (month < 10) {
return `${day}${separator}0${month}${separator}${year}`;
} else {
return `${day}${separator}${month}${separator}${year}`;
}
@raco
raco / calculate-distance-in-km.ts
Last active May 15, 2020 19:20
Calculate distance in km between 2 positions
export function getDistanceFromLocationsInKm(
latStart: number,
longStart: number,
latEnd: number,
longEnd: number
): number {
const R = 6371; // Radius of the earth in km
const dLat = _deg2rad(latEnd - latStart);
const dLong = _deg2rad(longEnd - longStart);
const a =
@raco
raco / result_csv.json
Created June 2, 2019 21:20
result_csv
{
"21_WATCHING": {
"predominant": "Beta",
"responding_ratio": 1.299,
"preparation_ratio": 1.372
},
"21_RESPONDING": {
"predominant": "Alpha",
"responding_ratio": 1.565,
"preparation_ratio": 1.372
@raco
raco / algoritmo_muse.php
Created June 2, 2019 21:19
algoritmo_muse
try {
$rows = Excel::toArray(new ResultsImport, $csvFile);
// $rows = $results[0];
$rowsCount = count($rows);
$baseline_rows = 0;
$baseline_alphasum = 0;
$baseline_betasum = 0;
$tempArray = array();
@raco
raco / webpack.config.js
Created May 9, 2018 20:45 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@raco
raco / preview_image.js
Created May 2, 2018 00:36
Preview Image
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#preview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}