Skip to content

Instantly share code, notes, and snippets.

View Voltra's full-sized avatar
🎯
Focusing

Voltra

🎯
Focusing
View GitHub Profile
@Voltra
Voltra / FilamentFabricatorController.php
Last active November 26, 2023 11:26
filament-fabricator with spatie/laravel-translatable
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Str;
use Spatie\RouteAttributes\Attributes\Fallback;
use Spatie\RouteAttributes\Attributes\Get;
use Spatie\RouteAttributes\Attributes\Where;
@Voltra
Voltra / owning.hpp
Created August 18, 2023 21:15
Opaque owning pointer
#include <memory>
template <class T, class Deleter = std::default_delete<T>>
class owning_ptr {
private:
T* ptr;
Deleter deleter;
explicit owning_ptr(T* rawPtr, Deleter d = {}) : ptr{rawPtr}, deleter{d} {}
@Voltra
Voltra / ffmpeg.bash
Created March 12, 2023 07:03
ffmpeg
ffmpeg -i <input file> -acodec copy -vcodec libx264 -crf 20 <output file>
ffmpeg -i <input file> -acodec copy -vcodec hevc_nvenc -preset llhq -rc cbr_hq -gpu any <ouput file>
@Voltra
Voltra / init.lua
Created February 5, 2023 15:08
nvim config
-- Install packer
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
vim.cmd [[packadd packer.nvim]]
end
require('packer').startup(function(use)
@Voltra
Voltra / untrustworthy_devs_and_projects.md
Last active November 19, 2022 15:07
Non trustworthy OSS developers/projects

Non trustworthy OSS developers/projects

Developers/projects that have proven, by past actions in their repositories, to be untrustworthy

Other similar initiatives

Projects

@Voltra
Voltra / reactiveRefsHackMixin.js
Created August 4, 2022 14:28
(Vue 2) reactiveRefsHackMixin.js
/**
* Quite the hack-ish mixin, allows to have reactive computed properties that
* depend on data from `$refs` despite not being reactive itself
*/
export const reactiveRefsHackMixin = {
data() {
return {
/**
* Flag used to trigger computation of reactive data (do not edit manually)
* @private
@Voltra
Voltra / LICENSE.md
Last active July 31, 2022 17:12
No Malevolence extended MIT License

Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Copies or substantial portions of the Software cannot be used with malevolence, with the intent to cause harm, or for any other nefarious purposes (targetted or otherwise).

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOL

@Voltra
Voltra / types.ts
Created July 10, 2022 19:46
types.ts
export type MethodsOf<Obj> = {
[Key in keyof Obj]: Obj[Key] extends (...args: unknown[]) => unknown ? Key : never;
}[keyof Obj];
@Voltra
Voltra / fp.ts
Created July 5, 2022 20:43
fp.ts
export interface Semigroup<T, Self> {
concat(b: Semigroup<T, Self>): Semigroup<T, Self>;
sconcat(b: Semigroup<T, Self>): Semigroup<T, Self>;
stimes(n: number): Semigroup<T, Self>;
}
const decorateSemigroup = <T, Self>(sg: Partial<Semigroup<T, Self>>): Semigroup<T, Self> => {
sg.stimes = function(this: Semigroup<T, Self>, n: number): Semigroup<T, Self> {
let ret = this;
@Voltra
Voltra / index.ts
Last active June 20, 2022 18:22
JS extension methods
export type ArrayPartitionResult<T> = [left: T[], right: T[]];
const partitionArr = function<T>(this: T[], predicate: (item: T, i: number, arr: T[]) => boolean): ArrayPartitionResult<T> {
return this.reduce((partitions: ArrayPartitionResult<T>, item: T, i: number): ArrayPartitionResult<T> => {
const partitionIndex = predicate(item, i, this) ? 0 : 1;
partitions[partitionIndex].push(item);
return partitions;
}, [[], []] as ArrayPartitionResult<T>);
};