Skip to content

Instantly share code, notes, and snippets.

View KhaledElAnsari's full-sized avatar
🙄

Khaled Al-Ansari KhaledElAnsari

🙄
View GitHub Profile
@bmaupin
bmaupin / free-database-hosting.md
Last active July 28, 2024 13:31
Free database hosting
@faressoft
faressoft / javascript_deep_dive.md
Last active April 17, 2024 18:50
JavaScript Deep Dive to Crack The JavaScript Interviews
@msalahat
msalahat / match_arabic_hmaz_letter.js
Last active March 22, 2017 23:18
Match user search with hamza in Arabic ( أ، ا ، آ ، إ ) against a list of words - UTF8
let match_arabic = (user_input, word) => {
let user_input_regx = "";
for (let d = 0; d < user_input.length; d++) {
//البحث عن أ، ا ، آ و إ
let hamz_letters = ["أ", "ا", "آ", "إ"].join("|")
const hamz_regx = new RegExp(hamz_letters);
if (hamz_regx.test(user_input.charAt(d))) {
user_input_regx += "[" + hamz_letters + "]";
} else {
user_input_regx += user_input.charAt(d);
# Example ssh config file. Usually located in ~/.ssh/config (user) or /etc/ssh/ssh_config (system)
# This works on both linux and MacOS
# Basic ssh commands converted to ssh/config file format
# Simplest format
# Run with: "ssh blog" => (equivalent to: "ssh ubuntu@example.com" and "ssh -i ~/.ssh/id_rsa -p 22 ubuntu@example.com")
Host blog
@ljharb
ljharb / array_iteration_thoughts.md
Last active July 27, 2024 16:17
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@shagunsodhani
shagunsodhani / GloVe.md
Created September 18, 2016 15:53
Notes for GloVe paper

GloVe: Global Vectors for Word Representation

Introduction

  • Introduces a new global log-bilinear regression model which combines the benefits of both global matrix factorization and local context window methods.

Global Matrix Factorization Methods

  • Decompose large matrices into low-rank approximations.
@rraallvv
rraallvv / copy.js
Created June 18, 2016 17:55
[Node.js] copy dir recursively
var fs = require('fs');
var copy = function(srcDir, dstDir) {
var results = [];
var list = fs.readdirSync(srcDir);
var src, dst;
list.forEach(function(file) {
src = srcDir + '/' + file;
dst = dstDir + '/' + file;
//console.log(src);
var stat = fs.statSync(src);
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@vasanthk
vasanthk / System Design.md
Last active July 27, 2024 18:36
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate