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 / 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 / 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 / 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 / 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 / match.php
Last active January 17, 2023 19:50
PHP 8, `switch` VS `match`
<?php
$sDayPrefix = date('D');
$sMessage = match ($sDayPrefix) {
'Mon' => 'Hello Monday! Have a great week!',
'Tue' => 'Hello Tuesday! Have a great day!',
'Wed' => 'Happy hump day all!',
'Thu' => 'Almost the end of the working week!',
'Fri' => 'Yaay! Happy Friday!',
'Sat' => 'Enjoy your weekend! Have a great Saturday :)',
@pH-7
pH-7 / preserve-caps-column-names-postgresql.md
Created December 19, 2022 07:14
Preserve cases of column/table names with PostgreSQL

If you name your PostgreSQL table names or column names with caps like lowerCamel / UpperCamel cases, you will need to surround the column names/table name with double quotes to preserve the case of their names since our the columns in our database are lowerCamel case. Otherwise, Postgres wouldn’t find them as it would look for lowercase-only names.

@pH-7
pH-7 / caps-naming-convention-programming.md
Last active May 23, 2023 11:24
Naming Convention - Programming

Caps, programming

  • UpperCamel case for classes. e.g., MyClass {}
  • lowerCamel case for variable names. e.g., myVar = "";
  • snake_case for Python functions and other functions delimited with underscores _ e.g., my_function();
@pH-7
pH-7 / alfred-workflows.md
Last active April 25, 2024 16:29
My Alfred workflows

My Alfred productivity workflows

@pH-7
pH-7 / usa-states.ts
Created May 4, 2022 11:16
List of the US state names and their abbreviations, handy stored in an array containing an object for each state details. Enjoy 🥳
export default [
{
name: 'Alabama',
abbreviation: 'AL',
},
{
name: 'Alaska',
abbreviation: 'AK',
},
{
@pH-7
pH-7 / InvalidDayMomentException.php
Last active March 28, 2022 19:56
Source code of my YouTube tutorial about handling multiple exceptions with PHP 7.1 - https://www.youtube.com/channel/UCGqLuT0upPiocwYSnnmqt2g
<?php
class InvalidDayMomentException extends InvalidArgumentException
{
}