Skip to content

Instantly share code, notes, and snippets.

@sketchbuch
sketchbuch / gist:92e8d607d2b3a1563880
Created December 26, 2015 23:00
NEOS - Neos CMS vhost
NameVirtualHost *:80
<VirtualHost *:80>
ServerName neos.t3local
SetEnv FLOW_CONTEXT Development
ServerAlias www.neos.t3local
DocumentRoot /var/www/neos/Neos-2.1/Web
<Directory ~ "/var/www/neos/Neos-2.1/">
@sketchbuch
sketchbuch / typescript-http-status-codes.ts
Last active April 27, 2021 08:32
TS - Typescript HTTP Status Code Enums and Types
export enum HttpStatusCodes100 {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
EARLY_HINTS = 103,
}
export enum HttpStatusCodes200 {
OK = 200,
CREATED = 201,
@sketchbuch
sketchbuch / renderShallow.tsx
Last active January 24, 2020 07:05
TESTING - Shallow renderer with generic Typescript
import * as React from 'react'
import configureMockStore from 'redux-mock-store'
import { Provider } from 'react-redux'
import { shallow, ShallowWrapper } from 'enzyme'
export type StringObject = { [key: string]: string }
export type StoreData = { [key: string]: string | StringObject }
export interface RenderShallowWithReduxOptions<T> {
children?: React.ReactNode
@sketchbuch
sketchbuch / renderShallowWithRedux.tsx
Last active January 24, 2020 07:05
TESTING - Shallow render with Redux and genric Typescript
import * as React from 'react'
import configureMockStore from 'redux-mock-store'
import { Provider } from 'react-redux'
import { shallow, ShallowWrapper } from 'enzyme'
export type StringObject = { [key: string]: string }
export type StoreData = { [key: string]: string | StringObject }
export interface RenderShallowWithReduxOptions<T> {
children?: React.ReactNode
@sketchbuch
sketchbuch / example-typescript-predicate-type-guard.ts
Last active January 24, 2020 07:04
TS - Typescript example of a Predicate Type Guard
export interfac-e NpmContributors {
email?: string;
githubUsername?: string;
name: string;
url?: string;
}
export interface NpmMaintainer {
email: string;
@sketchbuch
sketchbuch / vsc-extension-detect-active-editor-language-change.js
Last active January 24, 2020 07:09
VSC - How to detect a change of the langauge used by the active editor in a VSC Extension
// Called when active editor language is changed:
// After the active editor language changes the content is "re-opened" so just listen for the open event
// And check the lang of the active editor
vscode.workspace.onDidOpenTextDocument(() => {
const editor = vscode.window.activeTextEditor
if (editor !== undefined) {
const {
document: { languageId },
} = editor;
@sketchbuch
sketchbuch / vsc-extension-use-view-when-condition.js
Last active January 24, 2020 07:07
VSC - An example of how to control visibility of a view container's views in a VSC Extension
// Update the value used by a view's "when" condition
// Can't use in getChildren()
vscode.commands.executeCommand('setContext', someContextVar, isVisibleBoolean);
// Package.json
/*
...
"views": {
@sketchbuch
sketchbuch / typescript-sytled-components.ts
Last active January 24, 2020 07:06
TS - Typescript Types For Styled Components
export const StyledImg = styled.img<StyledImgProps>`
position: relative;
`
// Overriding a styled component's styles
export const StyledIcon = styled(Img)<StyledIconProps>`
position: relative;
`
@sketchbuch
sketchbuch / mock-window-properties-jest.js
Last active January 24, 2020 07:06
TESTING - How to mock window properties in Jest
// Store original value to set back after tests
const previousInnerWidth = window.innerWidth
Object.defineProperty(window, 'innerWidth', {
configurable: true,
value: 400,
writable: true,
})
@sketchbuch
sketchbuch / flutter-coomands.txt
Last active January 24, 2020 07:05
FLUTTER - Commands Reference
Clear device caches:
===================
> flutter clean
Get packages
============
> flutter pub get