Skip to content

Instantly share code, notes, and snippets.

View hasparus's full-sized avatar

Piotr Monwid-Olechnowicz hasparus

View GitHub Profile
@hasparus
hasparus / merging.ts
Last active March 8, 2019 10:08
TypeScript Playground -- Merging types
// Paste this to typescriptlang.org/play or click the link the comments
type Expected = {
a: 1 | 2
b?: 1 | 2
c?: 1
d?: 1 | 2
e: 2
f?: 2
}
@hasparus
hasparus / code.fish.v2
Created October 5, 2018 10:00
Changed root from /mnt to /
set wslUserRegex "~|(\/d\/wsl-userdir)"
set winUserPath "D:/wsl-userdir"
set wslCodePath "'/d/universal-tools/Microsoft VS Code/bin/code'"
function code
set arg (string replace --regex $wslUserRegex $winUserPath $argv[1])
eval $wslCodePath $arg
end
@hasparus
hasparus / AvitEmojiStatus.psm1
Last active September 15, 2018 22:02
AvitEmojiStatus -- my powershell theme
# thank you Aaron -- https://www.aaron-powell.com/posts/2018-01-30-the-happy-powershell-prompt/
# and you, Jan -- https://github.com/JanDeDobbeleer/oh-my-posh/blame/master/Themes/Avit.psm1
#requires -Version 2 -Modules posh-git
$happyPrompts = @('👻'; '🤖'; '🖖'; '❤️'; '🌷'; '🐸'; '🍺'; '😀'; '🤜'; '🎉'; '🤟'; '👌'; '🌈'; '🗿'; '💯'; '🌋'; '🌌';)
$angryPrompts = @('👿'; '👹'; '😭'; '🤢'; '💀'; '👺'; '🕵️'; '🤷‍'; '🖕'; '🔥'; '🌡️'; '🔪';)
function Write-Random {
param([string[]] $arr)
Write-Prompt -Object " $($arr[(Get-Random -min 0 -max ($arr.Length))]) " -ForegroundColor $sl.Colors.PromptForegroundColor
@hasparus
hasparus / code.fish
Created September 13, 2018 21:37
Call VSCode from WSL fish shell.
set wslUserRegex "~|(\/mnt\/d\/wsl-userdir)"
set winUserPath "D:/wsl-userdir"
set wslCodePath "'/mnt/d/universal-tools/Microsoft VS Code/bin/code'"
function code
set arg (string replace --regex $wslUserRegex $winUserPath $argv[1])
eval $wslCodePath $arg
end
import { Fixture } from '../utils/Fixture';
import { GameLevelClass, GameLevelStateless } from './GameLevel';
const fixture1: Fixture<typeof GameLevelStateless> = {
component: GameLevelStateless,
namespace: 'GameLevel/typed',
props: {
player: {
name: 'Arthas2000',
import { ComponentClass, ComponentType, Ref } from 'react';
export type Fixture<T extends ComponentType<any>> = {
component: T;
init?: (arg: { compRef: Ref<T> }) => Promise<any>;
name?: string;
namespace?: string;
props: T extends ComponentType<infer X> ? X : never;
state?: T extends ComponentClass<any, infer S> ? S : never;
};
import React from 'react';
type Entity = {
name: string;
strength: number;
};
type Props = {
player: Entity;
enemy: Entity;
import GameLevel from './GameLevel';
export default {
component: GameLevel,
props: {
player: {
name: 'Arthas2000',
strength: 100,
},
enemy: {
#requires -Version 2 -Modules posh-git
#based on tehrob from oh-my-posh
function Write-Theme
{
param(
[bool]
$lastCommandFailed,
[string]
$with
const cssPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.css";
const { readFile, writeFile } = require('fs');
readFile(cssPath, 'utf-8', (err, content) => {
if (err) throw err;
writeFile(
cssPath,
content.replace(
/\.editor-container{/g,
'.editor-container{-webkit-font-smoothing: antialiased;'