Skip to content

Instantly share code, notes, and snippets.

View pH-7's full-sized avatar
:octocat:
πŸ’‘Creative Engineer πŸš€ Enjoying Learning New Exciting Things! πŸ˜‹ =>My Way of Life 🏝

β™š PH⑦ de Soriaβ„’β™› pH-7

:octocat:
πŸ’‘Creative Engineer πŸš€ Enjoying Learning New Exciting Things! πŸ˜‹ =>My Way of Life 🏝
View GitHub Profile
@pH-7
pH-7 / CounterApp.jsx
Last active January 26, 2023 02:09
Example of a React Counter with localStorage - https://www.youtube.com/@pH7Programming
import {useEffect, useState} from 'react'
import './App.css'
export const CounterApp = () => {
const storageKeyName = "count";
const retrieveCountValue = () => Number(localStorage.getItem(storageKeyName) || 0);
const [count, setCount] = useState(retrieveCountValue());
@pH-7
pH-7 / 6-digit-code.js
Last active June 9, 2024 02:06
Generate a One-Tine Password / One-Time Code unique 6-digit code
// generate a unique 6-digit OTP code
const generateOntTimeCode = () => Math.floor(Math.random() * 900000) + 100000;
@pH-7
pH-7 / setup-ssh-key.md
Last active May 26, 2023 06:17
How to setup SSH key for the first time on your Mac OS

Setup your SSH key

How to setup SSH key for the first time on your Mac OS

To setup your SSH key on your computer

  1. Type ssh-keygen -t ed25519 -C "<YOUR_NAME>@zambrero.com"
  2. Create a SSH config file to automatically load keys into the ssh-agent and store passphrases in your keychain
    touch ~/.ssh/config
  3. Open the config file with your default text editor
@pH-7
pH-7 / how-setup-lamp-server-mac-os.md
Last active August 12, 2023 04:59
How to setup PHP and MySQL on Mac

How to quickly setup a LAMP on MacOS

Install PHP 7.3 and MySQL 5.1+

First, let’s install the Mac dependency manager β€œHomebrew”

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@pH-7
pH-7 / DataFrameSample.R
Last active April 25, 2024 23:15
Data Frames, object structure in R
# create a data frame
user_df <- data.frame(
name = c("Alice", "Bob", "Charlie", "Dave"),
age = c(25, 32, 47, 19),
city = c("New York", "San Francisco", "Los Angeles", "Chicago"),
stringsAsFactors = FALSE
)
# view the data frame
user_df
@pH-7
pH-7 / zshrc
Last active January 25, 2025 06:16
Add Volta in your Linux/Mac ~/.zshrc or ~/.bashrc file - (not maintained anymore) New updates are now happening in https://github.com/pH-7/dotfiles/
# To add in your ~/.zshrc or ~/.bashrc file
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
@pH-7
pH-7 / install-ruby-rails-macos.md
Last active August 12, 2023 09:41
How to install Ruby 3 with Rails v7, on macOS?

How to install Ruby & Rails on macOS?

Here are the simple 4 steps to install Ruby 3 and Rails v7 on macOS

Step 1: Install Homebrew

First, open your Terminal and run the following steps (I personally use iTerm2).

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@pH-7
pH-7 / fix-no-matches-found-zsh.sh
Created August 12, 2023 04:52
Run the following in your terminal to fix the unescaped arguments with matching arguments with Z shell. This will fix errors such as "zsh: no matches found: head^" error
echo "\n# Allow unmatched wildcard expressions in zsh\nsetopt NO_NOMATCH" >> ~/.zshrc
@pH-7
pH-7 / library-versus-require-in-R.md
Last active August 25, 2023 12:00
Which one to load a library in R - "library()" VS "require()" in R

library VS require in R

When loading a library, always use library. Never use require

TL;DR: require breaks one of the fundamental rules of robust software systems, fail early. In a nutshell, this is because, when using require, your code might yield different, erroneous results, without signalling an error. This is rare but not hypothetical! Consider this code, which yields different results depending on whether {dplyr} can be loaded:

On the other hand, require does install the package if hasn’t been installed (whereas library doesn’t).


@pH-7
pH-7 / show-last-tags.sh
Last active May 1, 2024 00:37
Show the last three git tags (very handy) - https://github.com/pH-7
git tag --sort=-creatordate | head -n3