Skip to content

Instantly share code, notes, and snippets.

Avatar

Ali Yusuf AliYusuf95

View GitHub Profile
@AliYusuf95
AliYusuf95 / move-mouse.ps1
Created Sep 5, 2022
Prevent PC from sleep PowerShell script
View move-mouse.ps1
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 Sep 8, 2019
MongoDB driver module for NestJS with dynamic mongo connection creation per request and handling open connections
View interfaces.mongo-options.interface.ts
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
Android device Utils
View DeviceUtils.java
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
RxJava event bus implementation with subscribing and unsubscribing.
View RxBus.java
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 Sep 29, 2022
Websocket implementation using OkHttp3 with {event->data} message format to make your life easier.
View OnEventListener.java
public interface OnEventListener {
/**
* Invoked when new message received from websocket with {event, data} structure
*
* @param data Data string received
*/
void onMessage(String data);
}