Skip to content

Instantly share code, notes, and snippets.

View jenya239's full-sized avatar

Evgeniy Arshanskiy jenya239

View GitHub Profile
@jenya239
jenya239 / authentication.mjs
Created October 13, 2023 14:40
passport oauth (facebook) state in verify
this.strategy = new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
passReqToCallback: true,
profileFields: ['id', 'emails', 'name'],
callbackURL: '/oauth2/redirect/facebook',
store: true
}, (req, accessToken, refreshToken, profile, cb) => {
d(`\n\noauth state in verify = `, req.oauthState)
return cb(null, {})
@jenya239
jenya239 / Pageable.tsx
Last active October 18, 2022 22:20
fetchable by page
import React, {
createContext,
Reducer,
RefObject,
useCallback,
useContext,
useMemo,
useReducer,
useRef,
} from 'react'
const path = require('path')
const fs = require('fs')
const debug = console.log
const buildDirMap = (dirPath) => {
const map = {}
const items = fs.readdirSync(dirPath)
for (const name of items) {
map[name] = fs.statSync(path.join(dirPath, name), { throwIfNoEntry: false })
> label {
margin-top: 10px;
padding-left: 10px;
display: grid;
grid-template-columns: 12px auto;
gap: 12px;
input[type='checkbox'] {
appearance: none;
margin: 0;
import React, { Context, Reducer, useContext, useEffect, useMemo, useReducer } from 'react'
type Status = 'init' | 'processing' | 'error' | 'success'
interface IItemState<Item> {
id: number
stage: number
item: Item
status: Status
}
import React, { Context, Reducer, useContext, useMemo, useReducer } from 'react'
type ItemState<Item> =
| { status: 'loading'; id: number; item?: Item }
| { status: 'error'; id: number; error: string; item?: Item }
| { status: 'success'; id: number; item: Item }
interface IActions {
fetchItem: (id: number) => Promise<void>
reset: () => void
import React, { Context, Reducer, useContext, useMemo, useReducer } from 'react'
type Action<Value> =
| { type: 'request' }
| { type: 'success'; value: Value }
| { type: 'failure'; error: string }
| { type: 'reset' }
type Dispatch<Value> = (action: Action<Value>) => void
import React, { Context, useContext } from 'react'
export interface IEntityProviderProps<EntityType> {
children: React.ReactNode
context: Context<ValueType<EntityType>>
entity: EntityType | undefined
}
type ValueType<EntityType> = { initialized: true; entity: EntityType } | { initialized: false }
@jenya239
jenya239 / builder.ts
Created December 24, 2020 23:06
literals.ts
import * as fs from 'fs'
import * as pathModule from 'path'
import { Dir, DirItem, Root, File } from './file'
interface IResNode {
[key: string]: IResNode | string
}
const OUTPUT_JSON = './src/utils/settings.json'
@jenya239
jenya239 / .coffee
Last active September 22, 2020 15:28
virtual node
virtual_node_context =
nodes_map: new WeakMap
class StringNode
constructor: (@parent, @string)->
@context =@parent .context
try_render: ( container )->
el =$ '<div>'
el .append @string
@contents =el .contents()