Skip to content

Instantly share code, notes, and snippets.

View HamedFathi's full-sized avatar
🌎

Hamed Fathi HamedFathi

🌎
View GitHub Profile
public class Result
{
public bool Success { get; private set; }
public string Error { get; private set; }
public bool Failure
{
get { return !Success; }
}
@HamedFathi
HamedFathi / index.html
Created December 2, 2021 22:57 — forked from LucGranato/index.html
Monaco Editor Liquid Language
<div id="container" style="height:100%;"></div>
/* Attribution: http://techslides.com/how-to-parse-and-search-json-in-javascript */
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
// https://dev.to/ryansolid/building-a-reactive-library-from-scratch-1i0p
// https://www.youtube.com/watch?v=vHy7GRpTpm8&list=LL&index=3&t=514s
// https://codesandbox.io/s/0xyqf?file=/reactive.js:0-1088
// A Dependency has many different Subscribers depending on it
// A particular Subscriber has many Dependencies
type Dependency = Set<Subscriber>;
type Subscriber = {
execute(): void;
@HamedFathi
HamedFathi / ngpurge.js
Created February 11, 2023 09:15 — forked from brianroadifer/ngpurge.js
Angular PurgeCSS Script
// orignal author @dylanvdmerwe - https://dev.to/dylanvdmerwe/reduce-angular-style-size-using-purgecss-to-remove-unused-styles-3b2k
const exec = require("child_process").exec;
const fs = require("fs");
const path = require("path");
const chalk = require("chalk");
function removeUnusedCSS() {
var pathPrefix = process.argv.slice(2)[0];
// find the styles css file
const files = getAllFiles(`./${pathPrefix}/`, ".css");
@HamedFathi
HamedFathi / Option.ts
Created February 18, 2023 10:20 — forked from bcherny/Option.ts
Options in TypeScript!
// @see http://www.scala-lang.org/api/2.7.4/scala/Option.html
class Opt<A> {
value: A | null
// TODO: use constructor fn instead
static from<A>(value: A | null): Opt<A> {
return value == null ? None : Some(value)
}
@HamedFathi
HamedFathi / options-in-typescript.ts
Created February 18, 2023 10:20 — forked from bcherny/options-in-typescript.ts
Options in TypeScript
type None = {
flatMap<U>(f: (value: null) => Option<U>): None
getOrElse<U>(def: U): U
isEmpty(): true
map<U>(f: (value: null) => U): None
nonEmpty(): false
orElse<U>(alternative: Option<U>): Option<U>
}
type Some<T> = {
import { Browser, chromium, firefox, webkit } from "playwright";
import { afterAll, beforeAll, describe, it } from "vitest";
const browserTypes = process.env.ALL_BROWSERS
? [chromium, firefox, webkit]
: [chromium];
for (const browserType of browserTypes) {
describe(`browser:${browserType.name()}`, () => {
let browser: Browser;
@HamedFathi
HamedFathi / Program.cs
Created April 27, 2023 10:21 — forked from ErikNoren/Program.cs
ASP.NET Core 6 configuration settings stored in a SQL database and acts just like appsettings.json
//Snippet from Program.cs which adds the provider and sets up a Settings class to map the settings
using ErikNoren.Configuration;
using TestMvcWebApplication;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddSqlDatabase(config =>
{
//We can get the connection string from previously added ConfigurationProviders to use in setting this up
config.ConnectionString = builder.Configuration.GetConnectionString("DemoDatabase");
@HamedFathi
HamedFathi / readme.md
Created July 20, 2023 14:19 — forked from primaryobjects/readme.md
How to Configure AutoGPT with Azure OpenAI Active Directory Managed Identity

How to Configure AutoGPT with Azure OpenAI Active Directory Managed Identity

AutoGPT is an extension of ChatGPT to automatically run an agent to complete a solution without human intervention.

Normally, an OpenAI API key is used.

For Azure OpenAI, you must use either an API token or an Azure Active Directory account.

Loading an API Key with Azure Managed Identity