Skip to content

Instantly share code, notes, and snippets.

View jsCommander's full-sized avatar
💭
I may be slow to respond.

Konstantin jsCommander

💭
I may be slow to respond.
  • Batumi, Georgia
View GitHub Profile
// eslint-disable-next-line node/no-unpublished-require
const stylelint = require('stylelint');
const ruleName = 'css-vars';
const messages = stylelint.utils.ruleMessages(ruleName, {
undefinedCssVar: variable => `Expected variable to be defined: ${variable}`,
});
const regex = /--[\w-]+/g;
const definedVars = new Set();
@jsCommander
jsCommander / get_obj_value_with_type.ts
Created October 27, 2022 12:57
Get type of obj value
function shit<T extends {}, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
const x: {name: string; value: number} = {
name: '420',
value: 228,
};
const y = shit(x, 'name'); // string
@jsCommander
jsCommander / kerberos_sso.ts
Created August 16, 2021 16:35
kerberos_sso.ts
import kerberos from "kerberos";
import { NextFunction, Request, Response } from "express";
import config from "../../config";
import ldap from "../../utilities/ldap";
import { processRawUser } from "./ldapAuth";
import { AuthResponseError } from "../../utilities/errorModels";
import { RequestWithUser } from "interfaces";
import jwt from "jsonwebtoken";
import { getLogger } from "../../utilities/logger";
initPatient$ = createEffect(() =>
this.actions$.pipe(
ofType(ROUTER_NAVIGATION),
filter(
(action: RouterNavigationAction) =>
new URL(
window.location.protocol + window.location.hostname + action.payload.routerState.url
).pathname === '/patients/search'
),
export async function promiseAllWithLimit<T>(
promiseGenerators: Array<() => Promise<T>>,
poolLimit: number
): Promise<T[]> {
let currentIndex = poolLimit - 1;
const total = promiseGenerators.length;
const results: T[] = Array(total);
const next = async (index: number): Promise<void> => {
if (index >= total) {
const express = require("express");
const proxy = require("express-http-proxy");
const path = require("path");
const app = express();
const api = "localhost:8080";
app.all(
"/api/*",
proxy(api, {
$rootScope.mouseDown = (e) ->
setTimeout ->
b = e.button
t = $(e.target)[0]
if t.parentNode
c = $(t.parentNode)[0].className
i = 0
dd = c
while i < 3
t = $(t.parentNode)[0]