Skip to content

Instantly share code, notes, and snippets.

View Soul-Master's full-sized avatar
🐶
Busy as always

Soul_Master Soul-Master

🐶
Busy as always
  • Thailand
View GitHub Profile
@Soul-Master
Soul-Master / ConvertToIso.bat
Last active December 17, 2015 06:18
Automate script to convert all folders (must contains VIDEO_TS folder) in current directory into ISO file by batch file and ImgBurn. PS. credit to videohelp forum http://bit.ly/16rME4I
SET imgBurnPath="C:\Program Files (x86)\ImgBurn\imgburn.exe"
SET destination=A:\Series\Pentor
@for /d %%i in (*.*) do %imgBurnPath% /mode build /buildmode imagefile /src "%%i\" /dest "%destination%\%%i.iso" /FILESYSTEM "ISO9660 + UDF" /UDFREVISION "1.02" /VOLUMELABEL "%%i" /rootfolder yes /noimagedetails yes /start /close
@Soul-Master
Soul-Master / txt
Created May 11, 2017 11:42
RCPT e-Portfolio - Privacy Policy
We collect your information only with your consent; we only collect the minimum amount of personal information that is necessary to fulfill the purpose of your interaction with us; we don't sell it to third parties; and we only use it as this Privacy Statement describes. If you're visiting us from the EU: we comply with the Privacy Shield framework.
fetch('https://gist.githubusercontent.com/Soul-Master/b718ac808e73f7635270ea1eee551a2d/raw/bx.js')
.then(response => response.text())
.then(result => eval(result))
fetch('https://gist.githubusercontent.com/Soul-Master/b718ac808e73f7635270ea1eee551a2d/raw/bx.css')
.then(response => response.text())
.then(result => {
const node = document.createElement('style');
node.innerHTML = result;
document.body.appendChild(node);
/*
It's impossible to call constructor of mixin class. All default properties in TypeScript don't work.
*/
function applyMixins<T>(derivedCtor: any, ...baseCtors: any[]) {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
@Soul-Master
Soul-Master / dynamicService.ts
Last active April 23, 2019 06:13
Demo Code from What's New in TypeScript (BRK2150) at Microsoft Build 2018
export type TypeFromConstructor<T> =
T extends StringConstructor ? string :
T extends NumberConstructor ? number :
any;
export type MethodDefinition = {
[x: string]: StringConstructor | NumberConstructor;
};
export type ServiceDefinition = {
[x: string]: MethodDefinition
};
type JSONified<T> =
JSONifiedValue<T extends { toJSON(): infer U } ? U : T>;
type JSONifiedValue<T> =
T extends string | number | boolean | null ? T :
T extends Function ? undefined :
T extends Array<infer U> ? JSONifiedArray<U> :
T extends object ? JSONifiedObject<T> :
undefined;
interface MessageMap {
method1: { prop1: string };
method2: { prop2: string };
method3: { prop3: string };
}
export type RequestMessage<T> = {
[P in keyof T]: { action: P, data: T[P] }
}[keyof T];
@Soul-Master
Soul-Master / index.d.ts
Last active August 23, 2019 23:23
TypeScript Declaration file for Node.js package (server-timings) https://github.com/remy/server-timings
/// <reference types="node" />
declare module 'server-timings' {
import { RequestHandler, Request, Response, NextFunction } from 'express';
function ServerTimings(req: Request, res: Response, next: NextFunction): any;
module ServerTimings {
/**
* Record the start time
@Soul-Master
Soul-Master / getPropValue.ts
Last active September 14, 2020 12:35
Strongly-typed deep path
type PropType<T, Path extends string> =
string extends Path ? never :
Path extends keyof T ? T[Path] :
Path extends `${infer K}.${infer R}` ? K extends keyof T ? PropType<T[K], R> : never : never;
declare function getPropValue<T, P extends string>(obj: T, path: P): PropType<T, P>;
const obj = {
a:
{
@Soul-Master
Soul-Master / json.d.ts
Created February 3, 2022 08:46
JSON Type Definition
type JSONPrimitive<T> = number | boolean | string | null | T;
type JSONValue<T> = JSONPrimitive<T> | JSONArray<T> | JSONObject<T>;
type JSONObject<T> = { [k: string]: JSONValue<T>; };
interface JSONArray<T> extends Array<JSONValue<T>> {
}