Skip to content

Instantly share code, notes, and snippets.

View Tylerian's full-sized avatar
🍼
I liek Protein

Jairo Tylera Tylerian

🍼
I liek Protein
View GitHub Profile
@Tylerian
Tylerian / slice.go
Created July 3, 2023 11:30
slice Chunk functions for Golang
func Chunk[T any](collection []T, chunkSize int) []T {
length := len(collection)
remainder := 0
if length%chunkSize > 0 {
remainder = 1
}
numOfChunks := length/chunkSize + remainder
chunks := make([]T, 0, numOfChunks)
@Tylerian
Tylerian / use-previous.ts
Created August 10, 2020 10:49
React useTransition hook
import {
useRef,
useEffect
} from "react";
function usePrevious(value) {
// The ref object is a generic container whose current property is mutable ...
// ... and can hold any value, similar to an instance property on a class
const ref = useRef(); // Store current value in ref
@Tylerian
Tylerian / script.js
Created April 9, 2020 17:17
Dialing Codes Generator
/// https://developers.facebook.com/docs/accountkit/countrycodes/
/// Run on Chrome Tools Console
var json = "[";
var table = document.getElementsByClassName("class_of_the_table")[0];
for (var i = 0, row; row = table.rows[i]; i++) {
json += "{";
for (var j = 0, col; col = row.cells[j]; j++) {
if (j === 0) {
@Tylerian
Tylerian / VanillaGenericHostApplication.cs
Last active November 8, 2019 19:04
Vanilla AspNetCore
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@Tylerian
Tylerian / example-component.tsx
Created October 19, 2019 13:49
ViewModel Pattern for React
import React, {
useEffect,
useMemo
} from "react";
import {
ExampleComponentViewModel
} from "./example-component.viewmodel";
type ExampleComponentProps = {
@Tylerian
Tylerian / _app.tsx
Created October 18, 2019 16:09
Next.js with Apollo implementation
import NextApp, {
AppInitialProps
} from "next/app";
import {
ApolloClient
} from "apollo-client";
import {
ApolloProvider
@Tylerian
Tylerian / ST_Epgs3857_DWithin.sql
Last active November 13, 2023 18:33
ST_DWithin function implementation for MySQL 8.0
-- Made by Jairo Tylera
-- (github.com/Tylerian)
-- (c) 2019 - present
-- Released under MIT X11 License
CREATE
DEFINER=`root`@`localhost`
FUNCTION
`ST_Epgs3857_DWithin`(p1 POINT, p2 POINT, distance_mts FLOAT)
RETURNS
@Tylerian
Tylerian / script.js
Created September 30, 2019 13:47
Get AS Networks total traffic size in PeeringDB.com
var finalSpeed = 0;
document.querySelectorAll(".list[data-edit-target='api:netixlan'] .scrollable .speed")
.forEach(node => { finalSpeed += parseInt(node.textContent.replace("G", "")); });
console.log("AS Total Speed --> ", finalSpeed, "G");