Skip to content

Instantly share code, notes, and snippets.

@omarmosid
omarmosid / mockApi.ts
Created May 28, 2024 11:59
mock api call
// Define the async function with TypeScript
async function mockApiCall(delay: number): Promise<string> {
return new Promise((resolve) => {
setTimeout(() => {
resolve('Mock API call completed');
}, delay);
});
}
// Example usage
@omarmosid
omarmosid / shortcuts.md
Last active December 28, 2023 17:03
Omars VS Code Shortcuts

Collapse Everything

Cmd/Ctrl + k, Cmd/Ctrl + 0

Collapse Everything expect currently focused function/scope

Cmd/Ctrl + k, Cmd/Ctrl + -

@omarmosid
omarmosid / git-commands.md
Created July 12, 2023 11:25
Omars git cheatsheet

Pull from remote

git pull

Know what branch you are on

git branch
@omarmosid
omarmosid / command.sh
Created June 20, 2023 15:21
Kill ports
# Prints out pid
sudo lsof -i :5432
kill -9 <PID>
@omarmosid
omarmosid / example.json
Created June 19, 2023 10:58
json snippets
{
"uuid": {
"prefix": "uuid",
"body": [
"\"$UUID\""
],
"description": "Insert a UUID v4 id",
}
}
@omarmosid
omarmosid / main.go
Created June 19, 2023 10:57
Go snippets
{
"PrintF": {
"prefix": "prf",
"body": [
"fmt.Printf(\"\\n $1 %$2 \\n\", $1);",
],
"description": "fmt.Printf"
},
"PrintLn": {
"prefix": "prln",
@omarmosid
omarmosid / snippets.r
Last active March 13, 2022 03:09
Common R snippets
# Load Data
data = read.csv(file.choose())
# Basic Analysis
head(data)
tail(data)
str(data)
colnames(data)
summary(data)
class(data)
# Import Data
data=read.csv(file.choose(),na.strings = c("","NA"))
# head, tail, str, colnames, summary
head(data)
tail(data)
str(data)
colnames(data)
summary(data)
@omarmosid
omarmosid / normalizeData.js
Last active November 3, 2021 14:18
normalizeData for seeder
const fs = require("fs");
const myData = [...Add your data here];
const final = myData.map((item, index) => {
return {
// Add your object data here which goes into seeder
};
});
@omarmosid
omarmosid / getFreqCount.js
Last active October 29, 2021 15:21
Get count of items in an array using reduce
// Example array
let ar = [10, 20, 20, 10, 10, 30, 50, 10, 20];
// Count object
const countObject = ar.reduce((acc, curr) => {
if (acc[curr]) {
return {
...acc,
[curr]: acc[curr] + 1
}