Skip to content

Instantly share code, notes, and snippets.

View AliYusuf95's full-sized avatar

Ali Yusuf AliYusuf95

View GitHub Profile
@AliYusuf95
AliYusuf95 / move-mouse.ps1
Created September 5, 2022 08:17
Prevent PC from sleep PowerShell script
Add-Type -AssemblyName System.Windows.Forms
# Add-Type -Name ConsoleUtils -Namespace WPIA -MemberDefinition @'
# [DllImport("Kernel32.dll")]
# public static extern IntPtr GetConsoleWindow();
# [DllImport("user32.dll")]
# public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
# '@
# # Hide Powershell window
# $hWnd = [WPIA.ConsoleUtils]::GetConsoleWindow()
@AliYusuf95
AliYusuf95 / interfaces.mongo-options.interface.ts
Created September 8, 2019 14:02
MongoDB driver module for NestJS with dynamic mongo connection creation per request and handling open connections
import { ModuleMetadata, Type } from '@nestjs/common/interfaces'
/**
* Options that ultimately need to be provided to create a MongoDB connection
*/
export interface MongoModuleOptions {
connectionName?: string
uri: string
dbName: string
clientOptions?: any
@AliYusuf95
AliYusuf95 / DeviceUtils.java
Created May 7, 2017 13:40
Android device Utils
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.IntDef;
import android.telephony.TelephonyManager;
@AliYusuf95
AliYusuf95 / RxBus.java
Last active May 7, 2017 06:17
RxJava event bus implementation with subscribing and unsubscribing.
import android.support.annotation.NonNull;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Predicate;
import io.reactivex.subjects.PublishSubject;
@AliYusuf95
AliYusuf95 / OnEventListener.java
Last active August 1, 2024 08:55
Websocket implementation using OkHttp3 with {event->data} message format to make your life easier.
public interface OnEventListener {
/**
* Invoked when new message received from websocket with {event, data} structure
*
* @param data Data string received
*/
void onMessage(String data);
}