Skip to content

Instantly share code, notes, and snippets.

View kirillrogovoy's full-sized avatar
🍋

Kirill Rogovoy kirillrogovoy

🍋
View GitHub Profile
let debugCounter = 0
export function mmap<
RI,
A,
AE = A extends AR.AsyncResult<any, infer E>
? E
: A extends Promise<any>
? Error
: A extends R.Error<infer E>
@kirillrogovoy
kirillrogovoy / xstate-backend.md
Created December 13, 2022 10:13
Using XState on the back end

State machine code with no implementation:

const trainingMachine = createMachine<TrainingContext>({
  predictableActionArguments: true,
  id: 'training',
  initial: 'initial',
  context: {},
  states: {
    initial: {
      on: {
import AppKit
let FILE_TARGET_DIR = NSString.path(withComponents: [NSHomeDirectory(), "gtd/files/"])
let ns = NSPasteboard.general
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy_MM_dd_HH_mm_ss"
let fs = FileManager()

How to open all links in Incognito by default.

  1. Open Script Editor
  2. Create a new file and paste the code below
  3. Save it as /Applications/BrowserProxy.app
  4. Open the terminal and try opening a website with the new script: open -a /Applications/BrowserProxy.app https://google.com
  5. Install https://github.com/kerma/defaultbrowser and run defaultbrowser browserproxy to set the new script as the default browser
  6. Try clicking any links in external apps other than the browser itself and see them open in new Incognito tabs.

NOTE: I'm using Brave Browser as the target browser. You should change it to what suits your needs. Since Brave is a Chromium, changing every "Brave Browser" to "Google Chrome" should suffice.

type ID = number
type Developer = {
id: ID
githubLogin: string
}
type Posting = {
id: ID
host: Developer
@kirillrogovoy
kirillrogovoy / streams.js
Created September 10, 2017 07:34
An example of using object steams in Node
const fetch = require('node-fetch')
const { Transform, PassThrough } = require('stream')
// giving the starting point a meaningful name
const processRates = new PassThrough({
writableObjectMode: true,
readableObjectMode: true
})
const promiseResolve = new Transform({
diff --git a/app/Ag/Ctrl/Json/SubscriptionPoll.php b/app/Ag/Ctrl/Json/SubscriptionPoll.php
index 39349190dc..111aa2fb05 100644
--- a/app/Ag/Ctrl/Json/SubscriptionPoll.php
+++ b/app/Ag/Ctrl/Json/SubscriptionPoll.php
@@ -20,6 +20,8 @@ class Ag_Ctrl_Json_SubscriptionPoll extends XPHP_Ctrl
$vendorStatuses = BrSoftUserVendorStatus::findByBrSoftUser($brSoftUsers);
foreach ($brSoftUsers as $brSoftUser) {
$status = $vendorStatuses[$brSoftUser->id];
+ $status->user_error = 'Bad things happened';
+ $status->admin_error = 'ADMIN ERROR';p
@kirillrogovoy
kirillrogovoy / bot.js
Last active December 18, 2015 14:20
Some very tricky bot
window.bot = (function() {
var intervalId = null;
function start(baseBet) {
if (!baseBet) throw Error('Usage: bot.start(baseBet)');
var state = null;
var nextBetSum = baseBet;
var betIsMade = false;
intervalId = setInterval(function() {
var bannerText = $('#banner').text();
var balance = Number($('#balance').text());