Skip to content

Instantly share code, notes, and snippets.

View mohamedmansour's full-sized avatar
✔️
Available

Mohamed Mansour mohamedmansour

✔️
Available
View GitHub Profile
@mohamedmansour
mohamedmansour / app.html
Last active August 23, 2023 21:57
Transitive dependencies do not work with aliased package names
<!DOCTYPE html>
<html lang="en">
<head>
<title>Aliased</title>
</head>
<body>
<example-app></example-app>
<script type="module" src="./dist/app.js"></script>
</body>
</html>
@mohamedmansour
mohamedmansour / ethereum.lib.js
Created April 15, 2023 21:58
Beacon Chain: Calculate HEAD Slot
const GENESIS_TIME = "2020-12-01T12:00:23Z"
const MILLISECONDS_PER_SLOT = 12000
function toUTCTimestamp(time) {
return Date.UTC(
time.getUTCFullYear(),
time.getUTCMonth(),
time.getUTCDate(),
time.getUTCHours(),
time.getUTCMinutes(),
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
},
@mohamedmansour
mohamedmansour / geth-sync-status.js
Last active July 28, 2021 03:26
Geth Sync Status
//
// 8% ETA: 53 minutes @ 1477.9bps
// 9% ETA: 27 minutes @ 2918.6bps
// 9% ETA: 34 minutes @ 2323.4bps
// 10% ETA: 34 minutes @ 2304.8bps
// 10% ETA: 37 minutes @ 2149.6bps
// 11% ETA: 36 minutes @ 2186bps
// 11% ETA: 35 minutes @ 2268bps
// 12% ETA: 30 minutes @ 2630.4bps
//
@mohamedmansour
mohamedmansour / islamic_date.js
Created May 7, 2021 10:02
Convert Gregorian Date to Islamic Date (Hijri)
/**
* Uses JavaScripts Internationalization to convert a gregorian date into
* an islamic hijri date. The W3C Spec included a format "ca-islamic" which
* makes this all happen.
*/
export function getHijriDate(date = new Date()) {
const locale = navigator.language
return new Intl.DateTimeFormat(locale + '-u-ca-islamic', {
day: 'numeric',
month: 'long',
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@mohamedmansour
mohamedmansour / prysm_p2p_stats.json
Last active December 29, 2020 01:26
Prysm P2P Stats Dashboard for Grafana
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@mohamedmansour
mohamedmansour / get_validator_duties.py
Last active November 14, 2023 20:02
Get validator duties for Prysm (find largest gap in which to update for that $0.04 it will save/benefit you)
"""
Originally developed by https://github.com/pietjepuk2
Ported to Prysm by https://twitter.com/mohamedmansour
Support my gitcoin https://gitcoin.co/mohamedmansour
"""
import json
import math
import time
import urllib
import sys
@mohamedmansour
mohamedmansour / subtract_time.py
Created June 6, 2020 10:31
Measure how long any command takes on Windows
# Copyright (c) 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
This script converts two %time% compatible strings passed to it into seconds,
subtracts them, and prints the difference. That's it. It's used by timeit.bat.
"""
from __future__ import print_function
@mohamedmansour
mohamedmansour / launch.json
Created October 24, 2018 22:11
webpack-dev-server integration with vscode and typescript for react
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug",