Skip to content

Instantly share code, notes, and snippets.

Avatar

Emil Rosenius ERPedersen

View GitHub Profile
View Makefile
install:
gcc helloWorld.c -o ./opt
@ERPedersen
ERPedersen / reset-docker.sh
Created Aug 26, 2020
Reset docker environment
View reset-docker.sh
# 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 Jun 29, 2020
Laravel Envoyer - Log ACL
View fix-permissions.sh
# 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
Silence bash deprecation warning (MacOS)
View .bash_profile
# Silence bash deprecation warning (MacOS)
export BASH_SILENCE_DEPRECATION_WARNING=1
@ERPedersen
ERPedersen / .bash_profile
Created May 28, 2020
Add yarn to global path
View .bash_profile
# Add yarn to global path
export="${PATH}:$(yarn global bin)"
View unique-array.js
/*
* 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
Open PHPStorm from terminal (MacOS)
View .bash_profile
# 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 Oct 18, 2019
Nullable foreach loop in PHP
View nullable_foreach.php
<?php
// Initialize variable to null
$empty = null;
foreach ($empty ?? [] as $item) {
// Line never executed
}
// No error encountered
@ERPedersen
ERPedersen / .bash_profile
Created Oct 18, 2019
Add current git branch to terminal
View .bash_profile
# 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 Oct 18, 2019
Free blocked port
View .bash_profile
# 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