Skip to content

Instantly share code, notes, and snippets.

View rebolyte's full-sized avatar

James Irwin rebolyte

View GitHub Profile
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');

https://github.com/yjs/yjs/blob/main/INTERNALS.md

https://www.youtube.com/watch?v=0l5XgnQ6rB4 - internals

  • 5:20 - defining a type gives you a view into the Items in the CRDT structure. The type is responsible for taking the Items (a linked list) and representing that to the user
  • 7:15 - all types extend AbstractType
  • 7:50 - everything is a linked list. He implemented a sequence CRDT, and then added maps and XML elements on top of that.
  • 9:00 - codebase is small because basically everything is an Item.
  • 10:40 - AbstractType always has a list CRDT, and the _start property tells you the first item. Also always has a _map property which maps previously-defined arbitrary string to CRDT, which is the last item in the list CRDT. (This is Replace Operation Manager in the whitepaper.)
    • 14:06 - _map is a utility so if the AbstractType is actually storing a map you can look up the last value from the key
  • 16:44 - to store tree of directories and their files, you could have a Map that is the file name, and th
Function.prototype.myBind = function myBind(ctx, ...baseArgs) {
const that = this;
return function (...args) {
that.call(ctx, ...baseArgs, ...args);
}
}
function tester(...args) {
console.log(this.aProp, ...args);
const crypto = require("crypto");
const algorithm = "aes-256-ctr";
const password = "Password used to generate key";
// Key length is dependent on the algorithm. In this case for aes192, it is
// 24 bytes (192 bits). For ae256, 32 bytes.
// Use async `crypto.scrypt()` instead.
const key = crypto.scryptSync(password, "salt", 32);
// Use `crypto.randomBytes()` to generate a random iv instead of the static iv
// shown here.
const { Publisher, Subscriber } = require('zeromq');
const PORT = 5000;
const args = process.argv.slice(2);
const TOPIC = args[0] || 'doc1';
let n = 0;
@rebolyte
rebolyte / DefaultKeyBinding.dict
Created November 4, 2020 22:38 — forked from trusktr/DefaultKeyBinding.dict
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
<!DOCTYPE html>
<html>
<head>
<title>TM Mobile</title>
import React, { useState, FunctionComponent, createRef, DragEvent, ChangeEvent } from 'react';
import classNames from 'classnames';
import { useOnMount, isIE } from '@utilities';
export interface Props {
onFileAdded?: (value: File) => any;
disabled?: boolean;
classes?: string;
accepts?: string;
}
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
export interface LoggerOpts {
level: LogLevel;
}
export type LogMethods = {
[key in LogLevel]: (...messages: any) => void;
};
@rebolyte
rebolyte / typescript-intro.md
Last active May 13, 2020 23:17
TypeScript basic intro

TypeScript intro

James Irwin
7-Jun-2018

TypeScript is a typed superset of JavaScript. All JavaScript is valid TypeScript, and TS transpiles to JS to run in browsers (much like Babel transpiles ES6+ to ES5). In transpilation, all types are stripped out; you get type-checking at compile-time only (but run-time type-checking is needed much less because of it). It is developed by Microsoft, powers apps you know like VS Code, and is in use at companies like Lyft, Reddit, and Slack.

Definition files

TypeScript lets you use existing JavaScript libraries in a strongly-typed manner by providing type definition files, which are separate files that annotate a given library's API. When you go to import lodash, you will likely also want to import @typings/lodash, which will install a lodash/index.d.ts file in your dependencies. So