Skip to content

Instantly share code, notes, and snippets.

export type ConsList<T> = null | readonly [T, ConsList<T>];
function cons<T>(h: T, t: ConsList<T>): ConsList<T> {
return [h, t];
}
function head<T>(xs: ConsList<T>): T {
if (!xs) {
throw new Error("can't take head of empty ConsList");
}
@beerose
beerose / resize.tsx
Last active September 10, 2019 10:13
export const Component: React.FunctionComponent<Props> = ({ text }) => {
const container = React.useRef() as React.MutableRefObject<HTMLDivElement>;
const [textContainerWidth, setTextContainerWidth] = React.useState(0);
React.useLayoutEffect(() => {
handleTextContainerWidth();
}, []);
React.useEffect(() => {
window.addEventListener('resize' handleTextContainerWidth);
export type ApiError = {
error: string;
error_details?: string;
};
export interface TypedResponse<T = ApiError> extends Response {
status: (status: number) => TypedResponse<T | ApiError>;
send: (body: T | ApiError) => TypedResponse<T | ApiError>;
}
isMember(A, houses(A, _, _, _, _)).
isMember(A, houses(_, A, _, _, _)).
isMember(A, houses(_, _, A, _, _)).
isMember(A, houses(_, _, _, A, _)).
isMember(A, houses(_, _, _, _, A)).
isInMiddle(A, houses(_, _, A, _, _)).
isFisrt(A, houses(A, _, _, _, _)).
% house(Nationality, Color, Pet, Cigarette, Drink)
solve(Houses) :-
length(Houses, 5),
% Anglik ma czerwony dom
member(house(english,red,_,_,_), Houses),
% Hiszpan ma psa
member(house(spanish,_,dog,_,_), Houses),
% W zielonym domu pije się kawę
member(house(_,green,_,_,coffee), Houses),
export const listMeetings = (
groupId: GroupDTO['id'],
callback: QueryCallback
) =>
connection.query(
{
sql: /* sql */ `
SELECT
id, meeting_name, group_id, date
FROM
import { purify } from 'profanity-util';
import * as vscode from 'vscode';
export const purifyLogs = () => {
const {
activeTextEditor: { document },
} = vscode.window;
const workspaceEdit = new vscode.WorkspaceEdit();
'use strict';
import * as vscode from 'vscode';
import { purifyLogs } from './purifyLogs';
export function activate(context: vscode.ExtensionContext) {
const disposable = vscode.commands.registerCommand(
'extension.noProfanity',
purifyLogs
);
"activationEvents": [
"onCommand:extension.noProfanity"
],
"main": "./out/extension",
"contributes": {
"commands": [
{
"command": "extension.noProfanity",
"title": "No profanity 🤬"
}
'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)