Skip to content

Instantly share code, notes, and snippets.

View yallie's full-sized avatar

Alexey Yakovlev yallie

View GitHub Profile
@yallie
yallie / Turn off Screen.bat
Last active April 1, 2023 22:58 — forked from EugeneLoy/Turn off Screen.bat
Turns off the screen and locks the workstation
@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
@PedroMGMendes
PedroMGMendes / SingleAssemblyResourceManager.cs
Created March 3, 2020 11:21
C# custom ResourceManager loader for usage with ILRepack.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Resources;
namespace ILRepack
{
/// <summary>
/// SingleAssembly Resource Manager.
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)
@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
};
<?php
define('BOT_TOKEN', 'XXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX'); // place bot token of your bot here
function checkTelegramAuthorization($auth_data) {
$check_hash = $auth_data['hash'];
unset($auth_data['hash']);
$data_check_arr = [];
foreach ($auth_data as $key => $value) {
$data_check_arr[] = $key . '=' . $value;
@bboyle1234
bboyle1234 / DoubleExtensions.cs
Last active January 15, 2022 19:06
Humanizes numbers. Makes them human-readable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;
namespace Foo {
public static class DoubleExtensions {
@alexvcasillas
alexvcasillas / github-store.js
Created May 4, 2017 08:35
Async Fetching with MobX Actions
import fetch from 'node-fetch';
import { observable, action, runInAction } from 'mobx';
export default class GithubStore {
@observable searchName;
@observable user;
@observable repos;
@observable fetchingData;
constructor() {
@yallie
yallie / SelectAsync.cs
Last active April 25, 2017 21:12
Process IObservable<T> asynchronously keeping the same order of events — see this discussion: http://stackoverflow.com/questions/43314307/unwrapping-iobservabletaskt-into-iobservablet
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
@hediet
hediet / main.md
Last active March 11, 2024 15:05
Proof that TypeScript's Type System is Turing Complete
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"];
@ca0v
ca0v / debounce.ts
Last active May 9, 2024 13:31
Typescript Debounce
// 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);
}