Skip to content

Instantly share code, notes, and snippets.

View renesansz's full-sized avatar
🎯
Focusing

Renemari Padillo renesansz

🎯
Focusing
View GitHub Profile
@renesansz
renesansz / update_hosts.sh
Last active December 6, 2023 22:48
A shell script that updates your /etc/hosts file with adblock, malware blocking, and malicious URLs blocking based on https://github.com/StevenBlack/hosts.
#!/bin/bash
# Set the URLs for the hosts files
HOSTS_URLS=(
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
"https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-only/hosts"
"https://raw.githubusercontent.com/badmojr/1Hosts/master/Lite/hosts.txt"
"https://tgc.cloud/downloads/hosts.txt"
"https://raw.githubusercontent.com/d3ward/toolz/master/src/d3host.txt"
# Add more URLs as needed
@renesansz
renesansz / get_nearest_landmark.py
Created October 11, 2023 06:05
Nearest landmark computation based on lat/long coordinates
import math
def haversine(lat1, long1, lat2, long2):
# Radius of the Earth in kilometers
R = 6371
# Convert latitude and longitude from degrees to radians
lat1, long1, lat2, long2 = map(math.radians, [lat1, long1, lat2, long2])
# Differences in latitude and longitude
@renesansz
renesansz / sample.jsx
Last active May 25, 2023 05:08
Lazy load SVG import in React + Vite
import useLazyLoadSvg from "useLazyLoadSvg";
function TestComponent () {
const { url, Icon } = useLazyLoadSvg(() => import("your-svg-path.svg"))
return (
<img src={url} />
<<Icon />
)
}

Keybase proof

I hereby claim:

  • I am renesansz on github.
  • I am renesansz (https://keybase.io/renesansz) on keybase.
  • I have a public key whose fingerprint is 7A56 4743 87E8 4F8A D209 3721 DC20 A56B DC0C 79CA

To claim this, I am signing this object:

@renesansz
renesansz / composeFn.js
Last active July 7, 2022 21:40
A functional programming utility that composes functions from right to left.
/**
* A functional programming utility that composes functions from right to left.
*
* @param fns The functions to compose. Each function is expected to accept a single parameter.
* @returns The final function obtained by composing the given functions from right to left.
*/
export const compose = (...fns) =>
fns.reduceRight(
(prevFn, nextFn) =>
(...args) =>
@renesansz
renesansz / pre-commit
Last active March 1, 2022 03:32
Pre-commit lint checking. This will run eslint command for every diff (except deleted, unmerged files)
#!/usr/bin/env bash
lint_check() {
changes="$(git diff -r --exit-code --name-only --staged --diff-filter=duxb -C packages/$1 | grep -E '.*\.(js|jsx|ts|tsx)$')"
# Only execute lint check if response code from git diff is 0 (has changes)
if [ "$?" -eq 0 ]; then
echo -e "🔎 Running lint check for \033[1;34m$1\033[0m"
npm --prefix ./packages/$1 run es ${changes//packages\/$1\//.\/}
fi
# Cancel commit if the last npm run command raised an error code (non-zero)
@renesansz
renesansz / custom-style-controller.css
Created March 11, 2021 04:46
My custom PS4 Gamepad Viewer
html {
background: green;
}
@renesansz
renesansz / System Design.md
Created December 9, 2020 01:48 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@renesansz
renesansz / bot.js
Created April 16, 2019 11:47
bot code block
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
}
});
@renesansz
renesansz / bot.js
Last active October 20, 2020 03:03
discord greeter bot
// Run dotenv
require('dotenv').config();
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});