Skip to content

Instantly share code, notes, and snippets.

View Sunpacker's full-sized avatar
🤚
Busy

Sunpacker Sunpacker

🤚
Busy
View GitHub Profile
@Sunpacker
Sunpacker / block-transactions.ts
Created May 25, 2024 04:38 — forked from queerviolet/block-transactions.ts
Транзакции ДБ с Apollo Server
/**
* If your database provides block transactions, (like Sequelize,
* here: https://sequelize.org/master/manual/transactions.html) here's how to
* use them in Apollo Server:
*/
import { ApolloServerPlugin, GraphQLRequestContext } from 'apollo-server-plugin-base'
export interface Transactable<Txn> {
transact?: Transact<Txn>
@Sunpacker
Sunpacker / stepper.machine.ts
Created January 25, 2024 04:22
xstate machine
import { setup, fromPromise, assign } from 'xstate'
function fakeAuth() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, 1000)
})
}
package main
import (
"fmt"
"github.com/danrl/golibby/queue"
"github.com/danrl/golibby/stack"
"github.com/danrl/golibby/graph"
)
@Sunpacker
Sunpacker / The Technical Interview Cheat Sheet.md
Created January 18, 2024 14:04 — forked from danrl/The Technical Interview Cheat Sheet.md
This is TSiege's technical interview cheat sheet. Please find the original and updated at their gist page.

NOTE Forked from @TSiege on Fri 3. May, 2019

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

@Sunpacker
Sunpacker / bin_search.go
Created January 18, 2024 13:59 — forked from echohes/bin_search.go
binary search in Golang
package main
import (
"fmt"
)
func binary_search(arr []int, item int) int {
max := len(arr)
low := 0
for low <= max {
@Sunpacker
Sunpacker / pluggable_object.ts
Created January 14, 2024 08:53
Pluggable object (typescript/javascript)
class SelectionTool {
mode: MySelectionMode
mouseDown() {
const selected = findFigure()
if (selected !== null) {
this.mode = new SingleSelection(selected)
} else {
this.mode = new MultipleSelection()
@Sunpacker
Sunpacker / One_Dark__copy_.icls
Last active January 14, 2024 06:08
Github theme for IntelliJ IDEs
<scheme name="One Dark (Sunpacker)" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2024-01-14T10:07:24</property>
<property name="ide">WebStorm</property>
<property name="ideVersion">2023.3.2.0.0</property>
<property name="modified">2024-01-14T10:07:31</property>
<property name="originalScheme">One Dark (Sunpacker)</property>
</metaInfo>
<option name="CONSOLE_FONT_NAME" value="JetBrains Mono" />
@Sunpacker
Sunpacker / BuildOperateCheck.txt
Created December 16, 2023 11:11
BuildOperateCheck pattern
This pattern shows up repeatedly in FitNesse Acceptance Tests. You need to use several tables on a single page, in order to fully test a given requirement. These tables naturally fall into three categories:
Build: One or more tables to Build the test data. These tables are typically based upon a <UserGuide.ColumnFixture that has the equivalent of a valid() function. The rows in the table load and save data, and the valid() function returns a boolean indicating whether the data was valid and properly saved.
Operate: A table to operate on the data. This table is typically based upon a <UserGuide.ColumnFixture and has always had the equivalent of a valid() function. The columns specify the arguments of the operation and the valid() function performs the operation and return a boolean to indicate success.
Check: One or more tables to validate the operation. These fixtures might be of the style <UserGuide.ColumnFixture or <UserGuide.RowFixture. It is in these tables that the real acceptance tests are performed. T
@Sunpacker
Sunpacker / pattern-proxy.js
Created November 30, 2023 14:08 — forked from DmitriiNazimov/pattern-proxy.js
[JS ES6 Паттерн ЗАМЕСТИТЕЛЬ (proxy)] #js #ES6 #ООП Паттерны#
/**
*
* ПАТТЕРН ЗАМЕСТИТЕЛЬ (proxy)
* Предоставляет суррогатный объект, управляющий доступом к другому объекту.
*
* Заместитель это обертка, которая применяется в следующих случаях:
* 1. Ленивая инициализация (виртуальный прокси). Когда у вас есть тяжёлый объект,
* грузящий данные из файловой системы или базы данных.
* 2. Защита доступа (защищающий прокси). Когда в программе есть разные типы пользователей, и вам хочется
* защищать объект от неавторизованного доступа. Прокси может проверять доступ при каждом вызове и передавать
@Sunpacker
Sunpacker / pattern-bridge.js
Created November 29, 2023 15:55 — forked from DmitriiNazimov/pattern-bridge.js
[JS ES6 Паттерн МОСТ (bridge)] #js #ES6 #ООП #Паттерны
/**
*
* ПАТТЕРН МОСТ (bridge)
*
* Паттерн МОСТ - отделяет абстракцию от реализации, благодаря чему появляется возможность независимо изменять то и
* другое. Это структурный паттерн проектирования, который разделяет один или несколько классов на две отдельные
* иерархии абстракцию и реализацию, позволяя изменять их независимо друг от друга.
* Например у нас есть класс Круг, и мы хотим создавать круги разного цвета, для этого нужно будет создать подклассы
* Синий Круг, Желтый круг и т.д. А если потом появятся квадраты и треугольники, то для них тоже нужно будет создавать
* большое количество подклассов. В итоге иерархия будет огромной. Логичнее создать две независимых иерархии -