Skip to content

Instantly share code, notes, and snippets.

View inca's full-sized avatar

Boris Okunskiy inca

View GitHub Profile
@inca
inca / README.md
Last active January 16, 2023 16:56
Icons for NodeScript
  • Automation Cloud:
@inca
inca / RCE.md
Created November 11, 2022 08:48

Realtime Collaborative Editing

This document describes both high level and more in-depth aspects of realtime collaborative editing. If you're busy, here's a TL;DR:

  • users expect it
  • we need it
  • we can do it
  • we can sustainably support it
  • there are a number of problems to solve of various severity, all of them solvable
@inca
inca / json-schema.d.ts
Created July 17, 2020 12:40
JSON Schema Loose Type Annotations
export type JsonSchemaTypePrimitive = 'null' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
export type JsonSchemaType = JsonSchemaTypePrimitive | JsonSchemaTypePrimitive[];
export interface JsonSchema {
type?: JsonSchemaType;
// number
minimum?: number;
maximum?: number;
exclusiveMinimum?: number;
exclusiveMaximum?: number;
@inca
inca / slider-captcha.ts
Created March 10, 2020 17:24
Slider Captcha Solution Action
import { Element, Ctx } from '@ubio/engine';
export async function captchaSlider(el: Element, ctx: Ctx) {
const page = el.page;
// Obtain elements to interact with
const sliderEl = (await el.queryOne('.yidun_jigsaw', false))!;
const imageEl = (await el.queryOne('.yidun_bg-img', false))!;
// Get image resources (base64) so that we can send them for offscreen canvas processing
@inca
inca / Hex.cs
Last active April 28, 2024 06:42
[Unity] Simple Hex Grid System
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public static class HexVectorExtensions {
public static Vector2 WorldToPlanar(this Vector3 world) {
return new Vector2(world.x, world.z);
}
@inca
inca / generate-combinations.js
Last active March 26, 2024 13:39
Generate Combinations Without Repetition
function* generateCombinations(array) {
if (array.length == 0) {
return;
}
const head = array[0];
const tail = array.slice(1);
yield [head];
for (const comb of generateCombinations(tail)) {
yield comb;
yield [head].concat(comb);
@inca
inca / image-resize.js
Last active August 29, 2015 14:15
Canvas-based image resize
var ImageResize = module.exports = exports = function(file) {
this.originalFile = file;
this.backgroundColor = '#fff';
};
ImageResize.prototype.resize = function(width, height, mime, cb) {
mime = mime || 'image/jpeg';
var self = this;
var reader = new FileReader();
reader.onload = onLoadFile;