Skip to content

Instantly share code, notes, and snippets.

View goodwin64's full-sized avatar
:octocat:

Max Donchenko goodwin64

:octocat:
View GitHub Profile
graph = {'A': set(['B', 'C']),
'B': set(['A', 'D', 'E']),
'C': set(['A', 'F']),
'D': set(['B']),
'E': set(['B', 'F']),
'F': set(['C', 'E'])}
def dfs_paths(graph, start, goal):
stack = [(start, [start])]
while stack:
@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)
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
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`
extends ../../layout
block title
title CYPI: About us
block styles
link(rel="stylesheet" type="text/css" href="css/about.css")/
block content
.text
// 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',
// pathIds, pathNames, paths
export enum urlPathIds {
PATIENT_ID = 'patientId',
MEASUREMENT_ID = 'measurementId',
NOTE_ID = 'noteId',
}
export enum urlPathNames {
OVERVIEW = 'overview',
@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>;
@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 / 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