Skip to content

Instantly share code, notes, and snippets.

View standaniels's full-sized avatar

Stan Daniëls standaniels

View GitHub Profile
@standaniels
standaniels / git-prune.sh
Last active July 3, 2021 09:40
Prune local branches that do not exist on the remote anymore.
#!/bin/bash
function gprune() {
for branch in $(git branch --no-color --list --format='%(refname:short)'); do
# Keep branch if it exists on remote or if it's the current.
if git show-branch remotes/origin/$branch >/dev/null 2>&1 || [[ $(git branch --show-current) = $branch ]]; then
echo "✅ $branch";
else
git branch -D $branch > /dev/null && echo "❌ $branch";
fi
@standaniels
standaniels / sensor.yaml
Created June 24, 2021 09:39
Add disk usage sensor to Home Assistant
- platform: command_line
name: Disk Usage
command: >-
df -h / | sed 1d | awk '{ print "\{\"size\": \"" $2 "\", \"used\": \"" $3 "\", \"used\%\": " $5+0 "\}" }'
unit_of_measurement: "%"
json_attributes:
- "size"
- "used"
- "used%"
value_template: "{{ state_attr('sensor.disk_usage', 'used%') }}"
PHP Warning: Uncaught ErrorException: require(/home/vagrant/pap/site/database/factories/CategoryFactory.php): failed to open stream: Too many open files in /home/vagrant/pap/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php:275
Stack trace:
#0 /home/vagrant/pap/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php(275): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'require(/home/v...', '/home/vagrant/p...', 275, Array)
#1 /home/vagrant/pap/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php(275): require()
#2 /home/vagrant/pap/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factory.php(68): Illuminate\Database\Eloquent\Factory->load('/home/vagrant/p...')
#3 /home/vagrant/pap/site/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(83): Illuminate\Database\Eloquent\Factory::construct(Object(Faker\Generator), '/home/vagrant/p...')
#4 /home/vagrant/pap/site/vendor/laravel/framework/sr
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
@standaniels
standaniels / after.sh
Last active March 9, 2022 06:08
Create supervisor program for Laravel queue worker in Homestead
#!/bin/sh
# This script creates a supervisor program for the Laravel queue worker and writes
# the log to the storage folder of the project. It also starts the http server on
# port 9001 so you need to add this port forwarding to your Homestead.yaml file.
sudo sh -c 'echo "[inet_http_server]
port = 9001
username = homestead
password = secret
@standaniels
standaniels / .screenrc
Created March 9, 2018 13:13
~/.screenrc
startup_message off
defutf8 on
#caption always "%{= Wk}%-w%{= Bw}%n %t%{-}%+w %-=%c:%s"
#vbell on
autodetach on
hardstatus alwayslastline "%{.kc}%-w%{.kw}%n*%t%{-}%+w %= %c:%s %d/%m/%Y"
@standaniels
standaniels / dist.js
Created January 24, 2018 09:49
Show only my issues in milestone
(()=>{function e(){Array.from(document.querySelectorAll("[id^=issue_")).forEach(e=>{0===Array.from(e.querySelectorAll("img.from-avatar")).filter(e=>e.alt==="@"+document.querySelector('meta[name="user-login"]').getAttribute("content")).length&&(e.style.display="none")})}new MutationObserver(e).observe(document.querySelector(".issues-listing"),{subtree:!0,childList:!0}),e()})();
@standaniels
standaniels / whitespace.styl
Last active October 13, 2017 07:53
Whitespace helpers
$gutter-width = 20
$break-sm = 768
$break-md = 992
$break-lg = 1200
$breakpoints = { 'xs': 0 px, 'sm': $break-sm px, 'md': $break-md px, 'lg': $break-lg px }
for bp in $breakpoints
for i in (0...10)
$distance = i * $gutter-width px
@media (min-width $breakpoints[bp])
@standaniels
standaniels / whitespace.scss
Created October 13, 2017 06:59
Whitespace helpers
$breakpoints: xs, sm, md, lg;
@each $breakpoint in $breakpoints {
@for $i from 0 through 10 {
$distance: $i * 15;
$breakpointInPixels: 0;
@if $breakpoint == sm {
$breakpointInPixels: 768;
} @else if $breakpoint == md {
$breakpointInPixels: 992;
@standaniels
standaniels / _switch.scss
Last active June 22, 2017 19:11
Bootstrap switch checkbox
// Demo: https://jsfiddle.net/fjspx80x/2/
.switch > input[type="checkbox"] {
display: none;
}
.switch > label.toggle {
cursor: pointer;
height: 0;
position: relative;