Skip to content

Instantly share code, notes, and snippets.

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

Diluka Diluka

💭
I may be slow to respond.
  • Parsec Tech
  • Chongqing, China
  • 00:26 (UTC +08:00)
View GitHub Profile
@Diluka
Diluka / electron-edge-js-quick-start.log
Created January 4, 2023 16:01
electron-edge-js-quick-start_v22.0.1_logs
Last login: Wed Jan 4 23:53:29 on ttys003
➜ electron-edge-js-quick-start git:(master) ✗ COREHOST_TRACE=1 npm start
> electron-edge-js-quick-start@1.0.0 start
> electron --core .
objc[77098]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa48d1a3b0) and /Users/diluka/Source/electron-edge-js-quick-start/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x110000228). One of the two will be used. Which one is undefined.
Tracing enabled
CoreClrEmbedding::Initialize - Started
CoreClrEmbedding::Initialize - edge.node path is /Users/diluka/Source/electron-edge-js-quick-start/node_modules/electron-edge-js/build/Release
@Diluka
Diluka / nestjs-query-graphql.hotfix.ts
Last active September 28, 2022 04:03
add offset support in cursor pagination for nestjs-query
import { applyDecorators } from '@nestjs/common';
import { Field, Int } from '@nestjs/graphql';
import { CursorPagingType } from '@ptc-org/nestjs-query-graphql';
import { LimitOffsetPagerStrategy } from '@ptc-org/nestjs-query-graphql/src/types/connection/cursor/pager/strategies';
import { getOrCreateCursorPagingType } from '@ptc-org/nestjs-query-graphql/src/types/query/paging';
import { CannotUseWith } from '@ptc-org/nestjs-query-graphql/src/types/validators';
import { IsOptional, Min, Validate } from 'class-validator';
const CPT = getOrCreateCursorPagingType();
@Diluka
Diluka / crypto.util.ts
Last active May 7, 2021 10:25 — forked from legend80s/Crypto.js
AES/ECB/PKCS5Padding Cipher and Decipher of Node.js and can communicate with other languages
// modified based on [node.js AES/ECB/PKCS5Padding 与其他语言的加密解密通用](http://yijiebuyi.com/blog/13e2ae33082ac12ba4946b033be04bb5.html)
import crypto, { BinaryLike, Encoding } from 'crypto';
import _ from 'lodash';
export class CryptoUtil {
/**
* 加解密必须使用同一套 key 和 iv
* @param {String} algorithm 算法名称,比如 `aes-128-ecb`
* @param {String} key 秘钥
* @param {String} iv initialization vector,默认空字符串
@Diluka
Diluka / typeorm-nestjs-logger.ts
Created July 7, 2020 02:33
Integrate the nestjs logger into typeorm
/*
* Created by Diluka on 2020-06-29.
*
*
* ----------- 神 兽 佑 我 -----------
* ┏┓ ┏┓+ +
* ┏┛┻━━━━━━┛┻┓ + +
* ┃ ┃
* ┣ ━ ┃ ++ + + +
* ████━████ ┃+
@Diluka
Diluka / reinstall-xcode-cli-tools.sh
Created May 29, 2020 03:16
No Xcode or CLT version detected!
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
@Diluka
Diluka / crud.controller.ts
Created September 19, 2019 14:57
CRUD common query for sequelize with routing-controllers
import {
Authorized,
BadRequestError,
BodyParam,
ForbiddenError,
JsonController,
NotFoundError,
Put,
QueryParam
} from "routing-controllers";
@Diluka
Diluka / crud-swagger-enhancement.ts
Last active September 26, 2019 01:37
增强版的CRUD修饰器,整合常用的修饰器于一体,并且大量减少冗余的描述
/*
* Copyright under the Parsec Tech Co., Ltd. Version 1.0;
* you may not use this file except in compliance with the permit.
* Copyright (c) 2019 ChongQing Parsec Technology Corporation. All Rights Reserved.
* Version 1.0
*/
/*
* Created by Diluka on 2019-04-22.
*
@Diluka
Diluka / transform.spec.ts
Created April 10, 2019 09:03
test if module options is effect on body transform in @nestjsx/crud
import { Controller, INestApplication, Injectable } from '@nestjs/common';
import { RepositoryService } from '../../src/typeorm';
import { Company, ormConfig, User, UserProfile } from '../../integration/typeorm/e2e';
import { Crud, Override, ParsedBody, ParsedParams } from '../../src/decorators';
import { InjectRepository, TypeOrmModule } from '@nestjs/typeorm';
import { CrudController, FilterParamParsed } from '../../src/interfaces';
import { Test } from '@nestjs/testing';
import * as supertest from 'supertest';
import { CrudModule } from '../../src/module';
import { CrudConfigService } from '../../src/module/crud-config.service';
@Diluka
Diluka / typeorm-cls.patch.ts
Created March 22, 2019 03:22
Patch CLS support to typeorm using typeorm-transactional-cls-hooked
import { Repository } from 'typeorm';
import { BaseRepository, initializeTransactionalContext } from 'typeorm-transactional-cls-hooked';
initializeTransactionalContext();
for (const p of Object.getOwnPropertyNames(BaseRepository.prototype)) {
Object.defineProperty(Repository.prototype, p, Object.getOwnPropertyDescriptor(BaseRepository.prototype, p));
}
@Diluka
Diluka / color-adjust.ts
Created January 26, 2017 09:24
颜色处理-带色偏的灰度处理
function colorAdjustProcess(data, i) {
let R0 = 145, G0 = 170, B0 = 190; //基准色
let R = R0 / (R0 + G0 + B0), G = G0 / (R0 + G0 + B0), B = B0 / (R0 + G0 + B0); //分配比例
let L = 3; // 亮度增益倍率
//
let r = data[i] * 0.3086;
let g = data[i + 1] * 0.6094;
let b = data[i + 2] * 0.0820;