Skip to content

Instantly share code, notes, and snippets.

View skwid138's full-sized avatar
🐅
Tiger Style

Hunter Rancourt skwid138

🐅
Tiger Style
View GitHub Profile
<?php
/**
* The table Printer class has no dependencies and generates an array of strings
* out of an array of objects or arrays and the child properties that should be printed given by an array of strings
*
* Should result in something like the following:
* +------+---------------+----------------+---------------+
* | id | name | col_name_three | col_name_four |
* +------+---------------+----------------+---------------+

Git Tips

Moved files or directories and git thinks they're deleted and new vs renamed.
The following will resolve most of this assuming the file contents themselves have not changed too much.
git add . -A

Add only previsouly staged or deleted files andd exclude unstaged (new) files
git add -u

Add only a portion of the changes in a file

Helpful Commands

List containers

(The below are using the recomended commands although docker ps <options> would be identicle for now)

  • All containers: docker container ls -a
  • Running containers: docker container ls (docker ps is the exact same, but is no longer the recomended command)
  • All stopped containers: docker container ls -f "status=exited"
  • IDs of running containers: docker container ls -q
  • IDs of all containers: docker container ls -aq
  • Recently created containers: docker container ls -l
@skwid138
skwid138 / github-add-team-to-repos.js
Last active September 12, 2022 16:42 — forked from davidrleonard/add-team-to-repos.js
Add a new team to all Github repos in an organization
/*
* Adds the specificed team to all the repos in a Github organization.
* This is a tedious process in the UI.
* You'll need a version of node greater than 9 to run this
*
* https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions
*
* Instructions:
* 1. Copy this file somewhere locally on your computer, e.g. ~/addteamrepos.js
* 2. Fill in the uppercase variables below with the right values
#!/bin/bash
# Open Apps used when doing development
# Could also include "iTerm" if the script is set to run automatically
# As it is now it would likely be run from iTerm
declare -a apps=("JetBrains Toolbox"
"Viscosity"
"MySQLWorkbench"
"ClickUp"
@skwid138
skwid138 / pro_tips.md
Created October 21, 2019 14:26
Here are a few tips to make you awesome at Cacher.

Getting Started

Snippets are the most useful when you want to re-use a command or a specific code pattern. Here are a few we have in our library:

  • How to delete a git tag
  • Nginx configuration for staging server
  • Crash handler AWS Lambda function

Label everything

Disable darkmode for MySQL WorkBench

defaults write com.oracle.workbench.MySQLWorkbench NSRequiresAquaSystemAppearance -bool yes

Develoment with multiple remote repos

This can occur when using composer to manage dependencies. From the dependency directory git remote -v will list origin as well as composer. The branch will appear as hash.

If the branch exists on the remote already you can run git fetch --all before setting up the tracking.

I believe both of these acomplish the same thing

  • git checkout [branch] --track [remote]/[branch]
  • git checkout -b [branch] [remote]/[branch]
# Apache logs location on Ubuntu
cd /var/log/apache2
# Apache logs location on my local macOS
cd ~/Sites/logs
# Tail Logs, only show rows with specific info (like my ip address)
tail -f /var/log/apache2/[site].log | grep [search term]
# Search through zipped log files for some piece of data (ip/email etc.)
# List only directories in the current location
ls -d */
# List files and directories with permissions and dates
ls -lh
# Remove white-sapce (tabs, spaces, and new lines)
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' -e 's/[\t ]//g;/^$/d'