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 / 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 / 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 / cs.js
Created June 19, 2011 13:53
Disqus Chrome Extension Injection
// We just need to check if the IFrame origin is from discus.com
if (location.hostname.indexOf('.disqus.com') != -1) {
// Extract the textarea (there must be exactly one)
var commentBox = document.querySelector('#comment');
if (commentBox) {
// Inject some text!
commentBox.innerText = 'Google Chrome Injected!';
}
}
@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(),
@mohamedmansour
mohamedmansour / background.html
Created June 30, 2011 00:14
Local Storage Message Passing Chrome Extension
<!doctype html>
<script>
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.sendRequest(tab.id, {method: "getLocalStorage"}, function(response) {
var myObjectRetrieved = JSON.parse(response.data);
console.log(myObjectRetrieved);
});
});
// Automatically inject all pages with the content script when the extension
@mohamedmansour
mohamedmansour / background.html
Created January 3, 2011 18:13
Google Chrome Extension to upload a locally stored image to imgurl API service.
<!DOCTYPE html>
<html>
<head>
<script>
const API_KEY = 'SOME_KEY';
/**
* Use HTML5 Canvas to get the image data
* @param {HTMLImageElement} img An Image Tag
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
},
@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",
@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 / crawler.js
Created December 6, 2017 04:48
Node Crawler
const cheerio = require('cheerio')
const request = require('request')
const { URL } = require('url')
const async = require('async')
var links = {}
fetchAllLinks('https://crawl.codeferret.net/1.html', links, () => {
let listLinks = Object.keys(links).map(link => {return `"${link}"`})
console.log(`[\n ${listLinks.join(',\n ')}\n ]`)
})