Skip to content

Instantly share code, notes, and snippets.

View holmberd's full-sized avatar

holmberd holmberd

View GitHub Profile
@holmberd
holmberd / php-pools.md
Last active April 19, 2024 07:24
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@holmberd
holmberd / js-nestGroupsBy.md
Last active April 13, 2024 11:52
Dynamically create nested level groups by properties in Javascript

Dynamically create nested level groups by properties in Javascript

Code

/**
 * Creates nested groups by object properties.
 * `properties` array nest from highest(index = 0) to lowest level.
 *
 * @param {String[]} properties
 * @returns {Object}
@holmberd
holmberd / git-rebase-onto.md
Last active April 9, 2024 02:11
Git Rebase --onto

Linked Feature Branches

Consider a case where you have multiple features that all depending on each-other going into master at different times. Feature-C depends on Feature-B, and Feature-B depends on Feature-A and so on...

If we squash merge Feature-A into master we first have to resolve our base in Feature-B before it can be merged. Below is an example of resolving it after Feature-A has been merged into master (make sure master is up-to-date).

git fetch --all
@holmberd
holmberd / aws-ebs-ec2-howtos.md
Last active February 21, 2024 14:04
Attaching and Mounting EBS Volume to an EC2 Instance

Attaching and Mounting EBS Volume to EC2 Instance

Create

  • Create new EBS Volume in the correct Availability Zone
  • Attach new EBS Volume to EC2 Instance

Mount

  • Check filesystem type (ext4) sudo file -s /dev/xvd*
  • Find new disk sudo fdisk -l
  • Create filesystem sudo mkfs -t ext4 /dev/xvdf
@holmberd
holmberd / deploy-keys.md
Last active February 11, 2024 20:36
Setup GitHub repository SSH deploy keys

Setup GitHub repository SSH deploy keys

  1. Create GitHub repository in github and save the SSH repository url

  2. Init git on server in code directory

  • git init
  1. Create SSH keys on the server
  • ssh-keygen -t rsa -b 4096 -C your@email.here
  • Rename the key that doesn't end with .pub to repo-name.deploy.pem
@holmberd
holmberd / linux-kill-pts.md
Last active February 11, 2024 12:57
Kill tty/pts sessions in Linux

Kill user tty/pts sessions in Linux

Commands

  • w: show who is logged on and what they are doing
  • who: show who is logged on
  • tty: show current users pseudo terminal
  • ps -ft pts/1: get process id for the pseudo terminal
  • pkill: signal process based on name and other attributes
@holmberd
holmberd / github.md
Created January 11, 2024 19:03
Github Convinces

Auto create remote branch when pushing local branch.

git config --global --add --bool push.autoSetupRemote true

@holmberd
holmberd / go-notes.md
Last active December 9, 2023 01:03
Go Notes

Slices

// https://www.dolthub.com/blog/2023-10-20-golang-pitfalls-3/
type slice struct {
    array unsafe.Pointer
    len   int
    cap   int
}

sliceA := []int{1, 2, 3}
@holmberd
holmberd / rob-pikes-5-rules-of-programming.txt
Created November 1, 2023 15:32
Rob Pike's 5 Rules of Programming
Rob Pike's 5 Rules of Programming
Rule 1. You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.
Rule 2. Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.
Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)
Rule 4. Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.
Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.
Pike's rules 1 and 2 restate Tony Hoare's famous maxim "Premature
@holmberd
holmberd / assignments.md
Last active March 20, 2023 17:39
Assignments

Exercises

There are two exercises in this document that are expected to be completed.

The source-code for each exercise should live in a separate repository, Github or GitLab, and should be accessible to the reviewer of the assignment. Each repository should contain a README file explaining the purpose of the repository and how to run it locally.

For each exercise you are free to use whatever libraries and technologies you like, but a combination of Javascript/Typescript/React is preferred for the first exercise, and Nodejs/PHP for the second.

Please do your best to write production-quality code.

Once completed, links to both of the repositories should be sent to: insert@email.here