Skip to content

Instantly share code, notes, and snippets.

View itsalb3rt's full-sized avatar
🐋

Albert E. Hidalgo Taveras itsalb3rt

🐋
View GitHub Profile
@paulohfev
paulohfev / useKeyDown.ts
Last active September 25, 2023 15:33
useKeyDown hook w/ TypeScript
import { useEffect } from 'react';
import { KeyboardKey } from 'enums/keyboardKey';
export const useKeyPress = (callback: (T?: any) => void, keys: KeyboardKey[]) => {
const onKeyDown = (event: KeyboardEvent) => {
const wasAnyKeyPressed = keys.some((key) => event.key === key);
if (wasAnyKeyPressed) {
event.preventDefault();
callback();
@jbaranski
jbaranski / OracleOpenPort80Centos.md
Created September 26, 2020 02:00
Open Port 80 Oracle Cloud Compute Instance (CentOS)

Open Port 80 Oracle Cloud Compute Instance (CentOS)

FYI This was harder than it needed to be:

  1. Looking at your instance info, find VNIC section, click "Public Subnet".
  2. Click on your security list.
  3. Add a new entry with the following options:
  • "Stateless" = No, "Source" = 0.0.0.0/0, "IP Protocol" = TCP, "Source Port Range" = All, "Destination Port Range" = 80
  1. SSH to your instance.
  2. While SSH'ed in your instance, run command firewall-cmd --permanent --add-service=http.
  3. While SSH'ed in your instance, run command firewall-cmd --reload.
  4. Now start Apache, NGINX, or whatever server you need to on port 80. You can now access from the internet.
@reinvanoyen
reinvanoyen / terminal-prompt-git-branch-zsh.md
Last active June 25, 2024 05:27
Add Git Branch Name to Terminal Prompt (MacOS zsh)

Add Git Branch Name to Terminal Prompt (zsh)

Updated for MacOS with zsh

  • Catalina
  • Big Sur
  • Monterey
  • Ventura
  • Sonoma

screenshot

@itsalb3rt
itsalb3rt / main.js
Created August 29, 2019 11:55
Validar cédula dominicana, con guiones y sin guiones Javascript
function isValid(str) {
var regex = new RegExp("^[0-9]{3}-?[0-9]{7}-?[0-9]{1}$");
if (!regex.test(str)) {
return false;
}
str = str.replace(/-/g, '');
@estorgio
estorgio / Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver).md
Last active June 27, 2024 07:07
Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

This guide will walk you through the steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest.

Prerequisites

This guide assumes that you are using the following setup:

You could still make this guide work with other setups (possibly with some modifications to the commands and whatnot).

@itsalb3rt
itsalb3rt / create_elements
Last active May 21, 2019 15:57
Crear elementos del doom utilizando javascript
function createElement(tagName, id = null, __class = null, src = null,customAtribute = null) {
let element = document.createElement(tagName);
element.setAttribute('id', (id == null) ? '' : id);
if (Array.isArray(__class)) {
__class.forEach(item => {
element.classList.add(item);
});
} else {
element.classList.add((__class == null) ? 'none' : __class);
@rcdexta
rcdexta / find.js
Last active April 12, 2019 23:44
_.find vs native find
const users = [
{ 'user': 'joey', 'age': 32 },
{ 'user': 'ross', 'age': 41 },
{ 'user': 'chandler', 'age': 39 }
]
// Native
users.find(function (o) { return o.age < 40; })
//lodash
$obj_merged = (object) array_merge((array) $obj1, (array) $obj2);
@idoshamun
idoshamun / loadState.js
Created October 8, 2018 15:49
Optimistic Offline-First Apps With Vuex
import store from './store';
import { getState } from './storage';
export default function () {
if (store.initialized) {
return Promise.resolve();
}
return getState()
.then(state => store.commit('loadFromCache', state));
@idoshamun
idoshamun / store.js
Created October 8, 2018 15:42
Optimistic Offline-First Apps With Vuex
import Vue from 'vue';
import Vuex from 'vuex';
import cache from './plugins/cache';
import sync from './plugins/sync';
Vue.use(Vuex);
export default new Vuex.Store({
state: {