Skip to content

Instantly share code, notes, and snippets.

View goodwin64's full-sized avatar
:octocat:

Max Donchenko goodwin64

:octocat:
View GitHub Profile
import path from 'path';
import express from 'express';
import fileUpload from 'express-fileupload';
import { pythonRunningProcess, spawnPythonProcess } from './spawn-python-process';
import { useRunningPythonServer } from './use-running-python-server';
const downloadsFolder = path.resolve(__dirname, './downloads');
let isProcessing = false;
@goodwin64
goodwin64 / bulkRenamer.js
Last active November 21, 2021 15:46
File counter rename script (0 external dependencies)
// only built-in Node.js dependencies
const fs = require('fs')
const path = require('path')
const util = require('util')
// working dir
const dir = 'C:\\Users\\werey\\Documents\\Scanned Documents'
// difference between file name counter and page number on image
const offset = 5
@goodwin64
goodwin64 / UserProfileList.tsx
Created April 26, 2021 16:09
UserProfileList fix
/* Given gist shown the "fetch-on-render" patter - the most popular, but with
the "waterfall" downside.
"Waterfall" means starting fetching AFTER rendering process is finished.
This task implies to show the "render-as-you-fetch" pattern - to start these 2
processes simultaneously. To achieve it the requests should be sent not in the
useEffect (coupled with rendering) but in Relay's layer often called "resource".
Under the hood this "resource":
1. either throws the contract-based object and the nearest <ErrorBoundary/> parent catches it
@goodwin64
goodwin64 / windvane-1-impl.ts
Last active October 29, 2021 18:27
Implementation of a tiny react-router helper utility
import mapValues from 'lodash/mapValues';
export type WindvanePaths<PNms, PIds, Pths> = {
[key in keyof Pths]: Array<keyof PNms | keyof PIds>;
}
export interface WindvaneOptions<PNms, PIds, Pths> {
pathNames: PNms;
pathIds: PIds;
pathsConcatScheme: WindvanePaths<PNms, PIds, Pths>;
// pathIds, pathNames, paths
export enum urlPathIds {
PATIENT_ID = 'patientId',
MEASUREMENT_ID = 'measurementId',
NOTE_ID = 'noteId',
}
export enum urlPathNames {
OVERVIEW = 'overview',
// windvane.test.ts
import {windvane} from '../../../services/RoutingService/windvane';
describe('windvane URL util', () => {
const wv = windvane({
pathNames: {
locations: 'locations',
new: 'create',
users: 'people',
about: 'about',
extends ../../layout
block title
title CYPI: About us
block styles
link(rel="stylesheet" type="text/css" href="css/about.css")/
block content
.text
Goldbach's conjecture is one of the oldest and best-known unsolved problems in number theory and all of mathematics. It states:
Every even integer greater than 2 can be expressed as the sum of two primes.
For example:
`6 = 3 + 3`</br>
`8 = 3 + 5`</br>
`10 = 3 + 7 = 5 + 5`</br>
`12 = 5 + 7`
def get_col_name(col):
abc = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"
col_name = ""
while col > 0:
letter_index = col % 26
if letter_index == 0:
letter_index = 26
col -= 26
col //= 26
col_name = abc[letter_index] + col_name
@goodwin64
goodwin64 / lab3_var3_maxflow.py
Created January 24, 2016 21:00
Non-elegant calculating the maximal flow.
class Vertex:
def __init__(self, name, value=1, connections={}):
self.name = name
self.value = value
self.connections = connections
def __repr__(self):
return "%s(%d)" % (self.name, self.value)