Skip to content

Instantly share code, notes, and snippets.

@aayushmau5
aayushmau5 / GSoC-2021.md
Created August 21, 2021 14:35
Project report for GSoC 2021

Project Report - GSoC 2021

Organization - Postman

Sub-Organization - AsyncAPI

Project - AsyncAPI Diff

Mentor - Vinit Shahdeo, Anubhav Vats

@aayushmau5
aayushmau5 / distro-hopping.md
Last active February 8, 2022 17:33
Things I do before/after distro hopping

Todo before /home cleanup

  • Commit projects
  • Backup movies/photos/other stuff
  • Update dotfiles(& commit)
  • Backup fonts

Softwares to install

  • Docker
@aayushmau5
aayushmau5 / Sophos-deno-login.ts
Created February 20, 2022 10:45
Deno code for Sophos login
enum AuthRequestType {
LOGIN,
LOGOUT,
}
function authRequest(
url: string,
username: string,
password: string,
authRequest: AuthRequestType

Mongosh in Docker

Connect

docker exec -it <container_name> mongosh -u <user_name> -p <password>

With -u an -p options being optional(obv).

Commands

@aayushmau5
aayushmau5 / todolist_genserver.ex
Created June 20, 2022 17:38
TodoList using GenServer in elixir
defmodule TodoList do
defstruct auto_id: 1, entries: %{}
use GenServer
def start do
GenServer.start(TodoList, nil)
end
def add_entry(pid, entry) do
GenServer.cast(pid, {:put, entry})
@aayushmau5
aayushmau5 / ansi.ex
Created November 3, 2022 16:21
Elixir strip ansi
def strip_ansi(text) do
# Taken from: https://github.com/chalk/strip-ansi/blob/main/index.js
# Original regex from https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js#L2 contained \u
# But PCRE doesn't support \u, it uses \x instead
# See: https://stackoverflow.com/questions/3538293/regular-expression-pcre-does-not-support-l-l-n-p
ansi_regex =
~r/[\x{001B}\x{009B}][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\x{0007})|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/
String.replace(text, ansi_regex, "")
end
# Projman - A project manager written in elixir.
# Run using elixir projman.exs
# With projman, you can open your projects easily through the command line.
# 1. Save a project using its path, and the preferred editor you want to open the project in.
# 2. Select the project you want to open, and this application will take care of opening the project for you.
Mix.install([:jason])
defmodule Projman do
def add_project(project_path, project_name, editor_command) do
@aayushmau5
aayushmau5 / asyncapi-diff.js
Created June 17, 2023 17:52
AsyncAPI diff quick prototype example
const {diff} = require('@asyncapi/diff');
const {Parser, fromFile} = require("@asyncapi/parser");
const parser = new Parser();
async function main() {
const firstDocumentFile = fromFile(parser, './test/fixtures/asyncapi_v1.yml');
const SecondDocumentFile = fromFile(parser, './test/fixtures/asyncapi_v2.yml');
const firstDocument = await firstDocumentFile.parse();
@aayushmau5
aayushmau5 / timer.sh
Last active June 19, 2023 16:23
Bash script that waits for certain minutes and then sends notification - PopOS!
# Warning: I used ChatGPT to write this bash script
#!/bin/bash
# Check if an argument is provided
if [ -z "$1" ]; then
echo "Please provide an integer argument."
exit 1
fi
defmodule TaskRunnerGenServer do
use GenServer
@impl true
def init(%{remote_node: remote_node} = args) do
# GenServer.start_link(TaskRunnerGenServer, %{remote_node: "REMOTE_NOTE_AT0M"}, name: TaskRunnerGenServer)
{:ok, %{ref: nil, node: remote_node}}
end
def start_task do