Skip to content

Instantly share code, notes, and snippets.

View ERPedersen's full-sized avatar

Emil Rosenius ERPedersen

View GitHub Profile
@ERPedersen
ERPedersen / Makefile
Last active October 21, 2020 13:05
Nicolai
install:
gcc helloWorld.c -o ./opt
@ERPedersen
ERPedersen / reset-docker.sh
Created August 26, 2020 13:58
Reset docker environment
# Remove all containers
docker rm $(docker ps -aq)
# Remove all images
docker rmi $(docker images -q)
# Remove the following:
# - all stopped containers
# - all volumes not used by at least one container
# - all networks not used by at least one container
@ERPedersen
ERPedersen / fix-permissions.sh
Created June 29, 2020 07:53
Laravel Envoyer - Log ACL
# Laravel Envoyer - Fix Log Permissions:
# ---
# Sets up access control restrictions, so both the deployment user 'forge'
# and the web-server's user 'www-data' can access generated log files.
PROJECT_DIRS="storage"
RELEASE_DIRS="bootstrap/cache"
cd {{ project }}
@ERPedersen
ERPedersen / .bash_profile
Created May 28, 2020 09:06
Silence bash deprecation warning (MacOS)
# Silence bash deprecation warning (MacOS)
export BASH_SILENCE_DEPRECATION_WARNING=1
@ERPedersen
ERPedersen / .bash_profile
Created May 28, 2020 09:05
Add yarn to global path
# Add yarn to global path
export="${PATH}:$(yarn global bin)"
@ERPedersen
ERPedersen / unique-array.js
Created May 28, 2020 09:03
ES6 Unique Arrays
/*
* Returns an array of unique values from the provided array.
*
* @param input {array} Array of values
* @returns {array} Array of unique values
*/
const unique = (input) => [...new Set(input)];
unique([1, 1, 2, 2, 3, 4]); // => [1, 2, 3, 4]
@ERPedersen
ERPedersen / .bash_profile
Created May 28, 2020 08:55
Open PHPStorm from terminal (MacOS)
# Opens the provided directory in PHPStorm. If PHPStorm is not currently running
# the application will be opened. If PHPStorm is already running, the provided
# directory will be opened in a new project window.
#
# Examples:
# Relative path: pstorm .
# Absolute path: pstorm ~/Projects/my-project
function pstorm () {
open -a PhpStorm $1
@ERPedersen
ERPedersen / nullable_foreach.php
Last active October 18, 2019 07:42
Nullable foreach loop in PHP
<?php
// Initialize variable to null
$empty = null;
foreach ($empty ?? [] as $item) {
// Line never executed
}
// No error encountered
@ERPedersen
ERPedersen / .bash_profile
Created October 18, 2019 07:39
Add current git branch to terminal
# Adds git branch to PS1 output
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\$ "
@ERPedersen
ERPedersen / .bash_profile
Last active October 18, 2019 07:36
Free blocked port
# Frees up the provided port by killing whatever process is blocking it.
#
# Example:
# freeport 8080
function freeport () {
local result=$(lsof -i :$1 | grep node | awk '{print $2}')
if [[ ! -z $result ]]; then
kill $result