type StringBool = "true"|"false";
interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };
type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: see https://www.makeuseof.com/tag/3-quickest-ways-turn-computer-screen-windows/ | |
:: see https://gist.github.com/EugeneLoy/150044d04b08e35d09e164c864e78da7 | |
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2) | |
:: see https://www.pcreview.co.uk/threads/create-a-batch-file-to-lock-computer.3747748/post-12994020 | |
Rundll32.exe User32.dll,LockWorkStation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Reflection; | |
using System.Resources; | |
namespace ILRepack | |
{ | |
/// <summary> | |
/// SingleAssembly Resource Manager. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using static System.Math; | |
namespace Foo { | |
public static class DoubleExtensions { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'node-fetch'; | |
import { observable, action, runInAction } from 'mobx'; | |
export default class GithubStore { | |
@observable searchName; | |
@observable user; | |
@observable repos; | |
@observable fetchingData; | |
constructor() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObservableExtensions | |
{ | |
public static IObservable<TResult> SelectAsync<TSource, TResult>( | |
this IObservable<TSource> src, | |
Func<TSource, Task<TResult>> selectorAsync) | |
{ | |
// using local variable for counter is easier than src.Scan(...) | |
var counter = 0; | |
var streamOfTasks = | |
from source in src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ts 3.6x | |
function debounce<T extends Function>(cb: T, wait = 20) { | |
let h = 0; | |
let callable = (...args: any) => { | |
clearTimeout(h); | |
h = setTimeout(() => cb(...args), wait); | |
}; | |
return <T>(<any>callable); | |
} |
NewerOlder