Skip to content

Instantly share code, notes, and snippets.

View ankon's full-sized avatar

Andreas Kohn ankon

View GitHub Profile
@ankon
ankon / schema-to-type.d.ts
Created December 18, 2020 11:05
JSON schema to TypeScript type
interface SchemaTypeNames {
'string': string;
'boolean': boolean;
'number': number;
// TODO: Could we recurse for 'array' and 'object'?
'array': any[];
'object': unknown;
}
import { Annotations, Args, BaseStory } from '@storybook/addons';
import React, { useState } from 'react';
import { CombinedUnion, Extension, fromHtml } from 'remirror/core';
import { BoldExtension } from 'remirror/extension/bold';
import { CodeBlockExtension } from 'remirror/extension/code-block';
import { ItalicExtension } from 'remirror/extension/italic';
import { UnderlineExtension } from 'remirror/extension/underline';
import { CorePreset } from 'remirror/preset/core';
import { RemirrorProvider, useManager, useRemirror } from 'remirror/react';
@ankon
ankon / object-keys-map.ts
Last active February 21, 2020 12:05
jscodeshift experiment: Object.keys(thing).map(k => thing[k]) --> Object.values(thing)
import { FileInfo, API, MemberExpression, CallExpression, Identifier } from 'jscodeshift';
function isExpression<T>(object: any, type: string): object is T {
return object.hasOwnProperty('type') && object.type === type;
}
function isMemberExpression(object: any): object is MemberExpression {
return isExpression<MemberExpression>(object, 'MemberExpression');
}
@ankon
ankon / consume-all-events.js
Created November 6, 2017 11:55
Consume all events in a kafka topic using rdkafka
function consumeAllEvents(kafkaBrokers, groupId, globalOptions, topic, handleEvent) {
const options = Object.assign({
'enable.auto.commit': false,
'group.id': groupId,
'metadata.broker.list': kafkaBrokers,
'socket.keepalive.enable': true,
}, globalOptions);
const topicOptions = {
'auto.offset.reset': 'earliest'
};
// Place your settings in this file to overwrite the default settings
{
"editor.renderIndentGuides": true,
"editor.renderWhitespace": "boundary",
"workbench.editor.closeOnFileDelete": false,
"files.autoSave": "onFocusChange",
"typescript.disableAutomaticTypeAcquisition": false,
"eslint.enable": true,
"eslint.run": "onType",
"zenMode.hideStatusBar": false,

Keybase proof

I hereby claim:

  • I am ankon on github.
  • I am ankon (https://keybase.io/ankon) on keybase.
  • I have a public key whose fingerprint is E2A9 155A FD3C 17E1 AD6A C0E0 B03F DDBC 66E9 9F92

To claim this, I am signing this object:

@ankon
ankon / pom.xml
Last active April 17, 2018 09:58
docker-maven-plugin and ECR
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>build</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
@ankon
ankon / .vscode_tasks.json
Last active November 12, 2019 10:35
VSCode: Incremental build with maven reactors
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "compile-server",
@ankon
ankon / rc.sh
Created June 10, 2016 05:34
No-frills init/rc replacement for running SysV services in a docker container
#!/bin/sh
# This is a wrapper script around a regular SysV service
_services=
while [ $# -gt 0 ]; do
if [ -x "$1" ]; then
_service=$1
shift
else
@ankon
ankon / filter-maven-travis.sh
Last active June 6, 2016 10:31
Taming Maven Verbosity on Travis
#!/bin/sh
# Filter maven output and inject 'travis_fold'/'travis_time' markers
exec awk '
BEGIN {
attn=0
id=0
start=0
end=0
}