Skip to content

Instantly share code, notes, and snippets.

View shalaby's full-sized avatar

Muhammad Shalaby shalaby

  • Egypt
View GitHub Profile
@shalaby
shalaby / typescript-crash.ts
Created April 23, 2022 11:10 — forked from bradtraversy/typescript-crash.ts
Basic intro to TypeScript (From YouTube Crash Course)
// Basic Types
let id: number = 5
let company: string = 'Traversy Media'
let isPublished: boolean = true
let x: any = 'Hello'
let ids: number[] = [1, 2, 3, 4, 5]
let arr: any[] = [1, true, 'Hello']
// Tuple
@shalaby
shalaby / mongodb_cheat_sheet_2022.md
Created January 24, 2022 14:55 — forked from codeSTACKr/mongodb_cheat_sheet_2022.md
MongoDB Cheat Sheet 2022
@shalaby
shalaby / clean.sh
Created December 21, 2021 08:46 — forked from Iman/clean.sh
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs
@shalaby
shalaby / service.js
Created May 20, 2021 15:47 — forked from cadebward/service.js
Remove `__v` and `_id` from MongoDB
import mongoose, {Schema} from 'mongoose'
export const ServiceSchema = new Schema({
displayName: {type: String, required: true, unique: true}
})
ServiceSchema.set('toObject', {
transform: function (doc, ret) {
ret.id = ret._id
delete ret._id
@shalaby
shalaby / index.js
Last active February 16, 2021 09:44
Simple news app using Mongo
const express = require('express')
const app = express()
const cors = require('cors')
app.use(cors())
// Mongoose
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/blog', { useNewUrlParser: true, useUnifiedTopology: true })
const db = mongoose.connection
// Listen on connection error
db.on('error', function (err) {
@shalaby
shalaby / index.js
Last active February 10, 2021 12:03
Simple news server.
const express = require('express')
const app = express()
const akhbar = []
app.get('/', function(req, res) {
const ahkbarHtml = akhbar.map(function(khabar, index) {
return `
<a href="/${index}"><h3>${khabar.title}</h3></a>
<p>${khabar.content}</p>
@shalaby
shalaby / index.js
Last active February 9, 2021 12:29
Simple blog server.
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: true }))
const posts = []
app.get('/', function (req, res) {
const postsHtml = posts.map(function (post) {
return `
@shalaby
shalaby / index.js
Last active February 9, 2021 09:29
Simple Todo server application.
const express = require('express')
const app = express()
let todos = []
app.get('/', function(req, res) {
const todosHtml = todos.map(function(todo, idx) {
let status = ''
if (todo.done == true) {
status = 'checked'