Skip to content

Instantly share code, notes, and snippets.

View lenconda's full-sized avatar
💻
Working and studying hard

Peng Hanlin lenconda

💻
Working and studying hard
View GitHub Profile
@lenconda
lenconda / readme.md
Created August 4, 2023 09:02 — forked from navix/readme.md
TypeScript Deep Partial Interface

TypeScript Deep Partial Interface

export type DeepPartial<T> = T extends Function ? T : (T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T);
type DeepPartial = {
@lenconda
lenconda / daemon.js
Created February 13, 2022 15:06
Daemonize & keep alive
const child_process = require('child_process');
const daemon = (pathname) => {
const child = child_process.fork(pathname);
child.unref();
return child;
};
module.exports = daemon;
@lenconda
lenconda / github.origin.js
Created July 5, 2021 10:42
Dollie Examples
const _ = require('lodash');
module.exports = async (id, config = {}) => {
if (!id) {
return null;
}
const [repository, checkout = ''] = id.split('@');
const token = config.token || '';
@lenconda
lenconda / chunk.js
Created January 4, 2021 08:59
chunk string into array
const chunk = (text: string, chunkSize = 128) => {
const traverse = (
currentResult: string[],
text: string,
chunkSize: number,
): string[] => {
if (!text || text.length === 0) {
return currentResult;
} else {
const currentSegmentation = text.slice(0, chunkSize);
@lenconda
lenconda / cloudSettings
Created September 18, 2020 03:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-18T03:12:55.547Z","extensionVersion":"v3.4.3"}
@lenconda
lenconda / meta
Last active March 16, 2020 15:25
site-description
{
"subtitle": "code. for. life."
}
@lenconda
lenconda / promisible.js
Last active January 15, 2020 08:37
promise implementation
function Promisible(executor) {
var _this = this;
_this.status = 'pending';
_this.result = null;
_this.reason = null;
_this.resolvedCallbacks = [];
_this.rejectedCallbacks = [];
function resolve(result) {
if (_this.status === 'pending') {
@lenconda
lenconda / Parallel_Tools_fix_for_Ubuntu_19.04.md
Created September 12, 2019 06:07 — forked from mag911/Parallel_Tools_fix_for_Ubuntu_19.04.md
Parallel Tools fix for Ubuntu 19.04

First off, credit goes to github.com/rudolfratusinski for leading the way here.

https://gist.github.com/rudolfratusinski/a4d9e3caff11a4d9d81d2e84abc9afbf

In a very similar approach, copy the files from the Parallels installation media and drop them in a folder somewhere (eg. ~/parallels_fixed)

Go to the kmods directory (cd ~/parallels_fixed/kmods) and extract the files (tar -xzf prl_mod.tar.gz)

Remove prl_mod.tar.gz file from that directory (rm prl_mod.tar.gz)

@lenconda
lenconda / consumer.ts
Created March 20, 2019 14:46
A producer-consumer model for RabbitMQ and test scripts
import config from '../../config/rabbitmq'
import { Consumer } from '../message_queue'
const consumer = new Consumer(config)
consumer.on('message', message => {
console.log(message)
})
@lenconda
lenconda / checker.js
Last active March 11, 2019 05:10
Check if remote service is available
const tcpp = require('tcp-ping')
const _ip = Symbol('ip')
const _port = Symbol('port')
class TCPChecker {
/**
* @constructor
* @param {string} address