Skip to content

Instantly share code, notes, and snippets.

View kadet1090's full-sized avatar
⛈️
Cloudy day

Kacper Donat kadet1090

⛈️
Cloudy day
View GitHub Profile
@kadet1090
kadet1090 / restart.php
Created April 19, 2014 14:53
If you've ever dreamed about restarting PHP from PHP script - here you go.
<?php
function restart() {
global $argv;
$cargs = [];
foreach($argv as $arg)
$cargs[] = strpos($arg, ' ') !== false ? '"'.$arg.'"' : $arg;
if(substr(PHP_OS, 0, 3) == 'WIN')
die((new \COM("WScript.Shell"))->Run(PHP_BINARY.' '.implode(' ', $cargs), 0, false));
@kadet1090
kadet1090 / prompt.ps1
Created March 21, 2016 17:33
PowerLine like prompt for PowerShell
$script:bg = [Console]::BackgroundColor;
$script:first = $true;
$script:last = 0;
function Write-PromptFancyEnd {
Write-Host  -NoNewline -ForegroundColor $script:bg
$script:bg = [System.ConsoleColor]::Black
}
@kadet1090
kadet1090 / Carbon.php
Created March 30, 2016 15:09
Simple month padder for calendars etc.
<?php
use Carbon\Carbon;
use Carbon\CarbonInterval;
/**
* Pads given month to whole weeks.
*
* @param int $year Year
* @param int $month Month
* @param int|string $firstDay First day of week index (0 for sunday) or name.
@kadet1090
kadet1090 / bot.py
Last active April 5, 2017 22:30
Some discord bot for counting scores
import discord
import asyncio
import re
client = discord.Client()
regex = {
'score': re.compile('<@!?(.*?)>\s*\+\s*(\d+|\+)')
}
@kadet1090
kadet1090 / popper.js.d.ts
Created August 16, 2018 11:48
Proper popper.js type definitions
declare class Popper {
static modifiers: (Popper.BaseModifier & { name: string })[];
static placements: Popper.Placement[];
static Defaults: Popper.PopperOptions;
options: Popper.PopperOptions;
constructor(reference: Element | Popper.ReferenceObject, popper: Element, options?: Popper.PopperOptions);
destroy(): void;
@kadet1090
kadet1090 / catascript.ts
Created January 21, 2021 22:04
Catamorphism in typescript
import React from "react";
interface FileItem {
type: "file";
fileName: string;
fileSize: number;
}
interface DirectoryItem<TItem> {
type: "directory";

New Document# Strong types for Vuex

Proof of concept for usage of [template literal types] for vuex stores and modules. For now it supports nested (namespaced and not) modules and checking mutation (name, payload) pairs but for now allows only argument style commit function.

TODO

  • Modules
    • Global VuexGlobalModule<TState, TMutations = {}, TActions = {}, TModules = {}, TGetters = {}>
    • Namespaced VuexNamespacedModule<TState, TMutations = {}, TActions = {}, TModules = {}, TGetters = {}>
    • State TState
      • State helper VuexState<TModule>