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 / 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 / gist:803631
Created January 31, 2011 04:11
Get and Set localStorage from Content Script
// Content Script to save data.
chrome.extension.sendRequest({storage: 'foo', value: 'bar'});
// Content Script to get data.
chrome.extension.sendRequest({storage: 'foo'}, function(response) {
console.log('foo => ' + response.storage);
});
// Background Page
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Html;
using Newtonsoft.Json;
namespace HtmlHelpers
{
/// <summary>
@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 / 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 / manifest.json
Created February 12, 2012 00:13
Chrome Extension to transfer the current selected webpage text to the popup
{
"name": "Selected Text",
"version": "0.1",
"description": "Selected Text",
"browser_action": {
"default_title": "Selected Text",
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
@mohamedmansour
mohamedmansour / background.html
Created January 8, 2011 18:02
Google Chrome Extension to override the Notifications API usage.
<html>
<script>
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
var notificationObj = request.NotificationCallback;
if (notificationObj) {
if (notificationObj.url) {
// HTML Notification.
}
else {
// TEXT Notification
@mohamedmansour
mohamedmansour / zerg_rush_google_cheat.js
Created April 27, 2012 22:14
Cheat Code to defeat the Google Zerg Rush!
// Mohamed Mansour 2012 http://mohamedmansour.com
var initEvent = function(element, str) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent(str, true, true);
element.dispatchEvent(clickEvent);
};
var simulateClick = function(element) {
initEvent(element, 'mousedown');
initEvent(element, 'click');
@mohamedmansour
mohamedmansour / click.js
Created July 16, 2011 01:09
Simulate a click in JavaScript for Google+ Share
function simulateClick(element) {
var clickEvent = document.createEvent("MouseEvents")
clickEvent.initEvent("mousedown", true, true)
element.dispatchEvent(clickEvent);
clickEvent = document.createEvent("MouseEvents")
clickEvent.initEvent("click", true, true)
element.dispatchEvent(clickEvent);
clickEvent = document.createEvent("MouseEvents")