Skip to content

Instantly share code, notes, and snippets.

@dminkovsky
dminkovsky / index.js
Last active August 3, 2022 14:36
periodicallyEmittingBuffer
const { rxObserver } = require('api/v0.3');
const { zip, timer, from, Observable } = require('rxjs');
const { take } = require('rxjs/operators');
const TIMEOUT = 1;
const TAKE = 6;
const alphabet$ = from('abcdefghijklmnopqrstuvwxyz');
alphabet$.pipe(
import jwt from 'jsonwebtoken';
interface Config {
teamId: string;
redirectUri: string;
keyId: string;
privateKey: string;
}
export default class AppleClientSecret {
const fs = require('fs');
const {join} = require('path');
module.exports = async function traverseFs(path, onFile) {
const stack = [];
let i = 0;
let files = await readdir(path);
while (i < files.length) {
const file = files[i];
if (file.isDirectory()) {
@dminkovsky
dminkovsky / machine.js
Created September 23, 2020 03:52
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'persist',
strict: true,
initial: 'idle',
on: {
UPDATE: {
target: 'updating',
},
},
states: {
import {useState, useEffect} from 'react';
import type safeAreaInsets from 'safe-area-insets'
type SafeAreaInsetsModule = typeof safeAreaInsets
export type SafeAreaInsets = Pick<SafeAreaInsetsModule, 'top' | 'right' | 'bottom' | 'left'>
// Written like this because of https://stackoverflow.com/q/62726153/741970
export default function useSafeAreaInsets() : SafeAreaInsets {
const [safeInsets, setSafeInsets] = useState({
export default class MessageUpdater {
constructor(id, environment) {
this._id = id;
this._environment = environment;
}
update({to, body}) {
const dirty = this._dirty();
var fs = require('fs');
var iconv = require('iconv-lite');
var input = 'Kino - Le dernier des heroes.cue';
var output = 'Kino - Le dernier des heroes.utf8.cue';
fs.createReadStream(input)
.pipe(iconv.decodeStream('win1251'))
.pipe(iconv.encodeStream('utf8'))
.pipe(fs.createWriteStream(output));
@dminkovsky
dminkovsky / cheatsheet.txt
Last active November 17, 2017 17:25
Kubernetes Cheatsheet
# Which cluster are you connect to?
$ kubectl cluster-info
$ kubectl config view context
For more detail: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/
# What's running?
$ kubectl get --all-namespaces all
users
.toStream()
.transform(() -> new Transformer<ByteString, Messages.User, KeyValue<ByteString, List<KeyValue<ByteString, Messages.User>>>>() {
private KeyValueStore<ByteString, Messages.User> store;
@Override
public void init(ProcessorContext context) {
store = (KeyValueStore<ByteString, Messages.User>) context.getStateStore("users-by-login-id-index");
}
<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>project</groupId>
<artifactId>streams</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>streams</name>