Skip to content

Instantly share code, notes, and snippets.

@ohnotnow
ohnotnow / stack.yml
Last active November 15, 2021 23:27
Basic stack
version: "3.7"
x-logging:
&default-logging
options:
max-size: '12m'
max-file: '5'
driver: json-file
x-healthcheck:
&default-healthcheck
@ohnotnow
ohnotnow / kitty.conf
Created August 27, 2018 14:38
Basic kitty config
# vim:fileencoding=utf-8:ft=conf:foldmethod=marker
Fonts {{{
#: kitty has very powerful font management. You can configure
#: individual font faces and even specify special fonts for particular
#: characters.
# font_family monospace
# bold_font auto
@ohnotnow
ohnotnow / SomethingBlewUp.php
Created July 27, 2018 16:00
Horrific mess slack laravel exception handler
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
@ohnotnow
ohnotnow / app.js
Created May 24, 2018 14:33
csrf hackyness
document.addEventListener("DOMContentLoaded", function () {
setInterval(keepTokenAlive, 1000 * 60 * 15); // every 15 mins
function keepTokenAlive() {
axios.get('/keep-token-alive')
.then(response => {
let token = response.data.token;
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = response.data.token;
const formFields = document.querySelectorAll('input[name="_token"]');
@ohnotnow
ohnotnow / minio.service
Created March 3, 2018 18:19
Minio systemd for rpi
# /storage/.config/system.d/minio.service
[Unit]
Description=minio server
# if we do network mounts like here we *require* 'network-online.service'
# which checks if the network is online
Requires=network-online.service
# our scripts must start *after* 'network-online.service', on timeout and if
@ohnotnow
ohnotnow / gist:bdd8f4e6f4eed6ec9b1d12c207b31d74
Last active February 19, 2018 10:27
Vuejs directive for pikaday
// npm install pikaday
// resources/assets/js/app.js
import Pikaday from "pikaday";
import "pikaday/css/pikaday.css";
Vue.directive("pikaday", {
bind: (el, binding) => {
el.pikadayInstance = new Pikaday({
field: el,
onSelect: () => {
@ohnotnow
ohnotnow / example.php
Created December 8, 2017 09:17
Rendering the contents of a laravel mail notification in a test
Notification::assertSentTo($user, MyNotification::class, function ($notification) use ($user) {
$markdown = app(\Illuminate\Mail\Markdown::class);
$mail = $notification->toMail($user);
dd($markdown->render($mail->markdown, $mail->data()));
});
@ohnotnow
ohnotnow / autostart.sh
Created December 2, 2017 15:47
Disabling wifi power management on rpi3/libreelec
# from : https://forum.libreelec.tv/thread/5074-wifi-issues-on-rpi-3-poor-speed-and-latency-solution/#codeLine_1_3e8919
# first install the 'network tools' add-on from the kodi repository then create a /storage/.config/autostart.sh file with
# this as the contents.
# then reboot the pi. runnning 'iwconfig' should now show the power-management as being off.
/storage/.kodi/addons/virtual.network-tools/bin/iw wlan0 set power_save off
@ohnotnow
ohnotnow / gist:c92c488fa106b303bbf615058cc4b925
Created September 30, 2017 09:27
ublock origin rule to hide 'user X liked....' in the feed
twitter.com##body:not(.NotificationsPage) li.stream-item:has(.Icon--heartBadge)
@ohnotnow
ohnotnow / gist:697cf121525602c9c63abe46dbdcd53f
Created October 7, 2016 11:54
Testing/mocking stdlib function
<?php
/*
This is a contrived example - but I'm working on a large PHPv4 style legacy codebase
and it's full of this kind of code (only much, much worse - c70,000 lines of raw
mysql calls etc).
So in this case I could use the 'namespace' mocking trick to mock all of the
functions - but to test things like "everything passes", "connection works, but TLS
fails", "password is wrong" etc, seems hard to do without the tests
getting really quite nasty. Combined with all the raw mysql* function calls it