Skip to content

Instantly share code, notes, and snippets.

View KhaledElAnsari's full-sized avatar
🙄

Khaled Al-Ansari KhaledElAnsari

🙄
View GitHub Profile
@rpivo
rpivo / index.md
Last active August 8, 2024 12:59
Encrypting & Decrypting Sensitive Data With the Web Crypto API

Encrypting & Decrypting Sensitive Data With the Web Crypto API

Chris Veness created a really great gist that shares code to encrypt and decrypt data using the Web Crypto API here.

This gist breaks down the code in that gist step by step, detailing a real-world scenario with actual data.

It might be helpful to have that gist open in another tab and use this gist to walk through each line of code.

One interesting use case for this would be to encrypt on a client, and then decrypt in the cloud with something like a Lambda function. In order to do this, you could use Node's latest version as of this gist, version 15, which includes a webcrypto module that's designed to be a Node implementation of the Web Crypto API. Lambdas can't use v15 by default -- however, you can create a custom Lambda layer that contains v15.

@bmaupin
bmaupin / free-database-hosting.md
Last active September 23, 2024 02:12
Free database hosting
@faressoft
faressoft / javascript_deep_dive.md
Last active September 7, 2024 16:47
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 September 6, 2024 04:53
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 September 23, 2024 06:28
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?