Skip to content

Instantly share code, notes, and snippets.

View hamzaajaved's full-sized avatar

Muhammad Hamza hamzaajaved

  • Karachi, Pakistan
View GitHub Profile
@hamzaajaved
hamzaajaved / .zshrc
Last active March 8, 2024 07:59
Shell Script
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@hamzaajaved
hamzaajaved / f.sh
Created March 7, 2024 19:50 — forked from LearnWebCode/f.sh
My fzf first draft
# You need to give this file permission to execute by doing the following...
# chmod +x f.sh
# Add an alias named f to your .zshrc file like this:
# alias f="/Users/brad/Documents/shell-scripts/f.sh"
code "$(find ~/Documents ~/Desktop ~/Sites ~/Local\ Sites -type d \( -name "node_modules" -o -name ".next" -o -name ".git" -o -name "vendor" -o -name "wp-includes" -o -name "wp-admin" \) -prune -o -type d | fzf)"
# todo someday
# currently it only searches for folders, but it would be nice if I could search for zshrc or specific files, but I'm not sure if that will include too many files and be slow...
@hamzaajaved
hamzaajaved / array_methods.js
Created May 19, 2022 07:19
JavaScript Array Methods
function forEach(array, cb) {
for (let i = 0; i < array.length; i++) {
cb(array[i], i, array)
}
}
function map(array, cb) {
const newArray = []
for (let i = 0; i < array.length; i++) {
newArray.push(cb(array[i], i, array))
export const validateEmail = email => {
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
};
export const getTrimString = string => {
return string.replace(/\s+/g, " ").trim();
};
@hamzaajaved
hamzaajaved / a_index.ts
Last active May 18, 2022 11:50
TypeScript Crash Course
// Basic Types
let id: number = 5
let company: string = 'Traversy Media'
let isPublished: boolean = true
let x: any = 'Hello'
// Built in Objects
let now:Date = new Date()
let ids: number[] = [1, 2, 3, 4, 5]
let arr: any[] = [1, true, 'Hello']
@hamzaajaved
hamzaajaved / file.js
Created February 1, 2022 18:34
Higher Order Function
const companies= [
{name: "Company One", category: "Finance", start: 1981, end: 2004},
{name: "Company Two", category: "Retail", start: 1992, end: 2008},
{name: "Company Three", category: "Auto", start: 1999, end: 2007},
{name: "Company Four", category: "Retail", start: 1989, end: 2010},
{name: "Company Five", category: "Technology", start: 2009, end: 2014},
{name: "Company Six", category: "Finance", start: 1987, end: 2010},
{name: "Company Seven", category: "Auto", start: 1986, end: 1996},
{name: "Company Eight", category: "Technology", start: 2011, end: 2016},
{name: "Company Nine", category: "Retail", start: 1981, end: 1989}
mongoose.connect('mongodb://localhost:27017/my-app', {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
});
const db = mongoose.connection;
db.on("error", console.error.bind(console, "connection error:"));
db.once("open", () => {
console.log("Database connected");
@hamzaajaved
hamzaajaved / Readme.md
Created September 1, 2021 17:36
JavaScript Wierd Parts
@hamzaajaved
hamzaajaved / .zshrc
Created April 27, 2021 22:02
Sync ZSHRC
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/hamza/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes