Skip to content

Instantly share code, notes, and snippets.

View munael's full-sized avatar

Muhammad N ElNokrashy munael

View GitHub Profile
@munael
munael / graph.py
Last active October 4, 2022 23:06 — forked from c0nn3r/graph.py
Nice graph formatting. (from c0nn3r)
import re
import os
import glob
import pandas as pd
import matplotlib.pyplot as plt
from collections import OrderedDict
fig_size = [12, 9]
@munael
munael / update_urls.js
Last active February 5, 2021 13:20
Update all active session URLs on Chrome
function fix_url(url) {
var bad = "";
var good = "";
return url.replace(bad, good);
}
chrome.tabs.query({}, function(tabs){
console.log(`Found ${tabs.length} tabs to update.`)
var _count = 0;
var n_changed = 0;
@munael
munael / dataclass_from_dict.py
Created September 18, 2019 23:03 — forked from gatopeich/dataclass_from_dict.py
Python 3.7 dataclass to/from dict/json
from dataclasses import dataclass, fields as datafields
from ujson import dumps, loads
# Note: ujson seamlessly serializes dataclasses, unlike stdlib's json
@dataclass
class Point:
x: float
y: float
# Shallow dataclass can be rebuilt from dict/json:
@munael
munael / constexpr(expr).md
Last active April 6, 2019 22:56 — forked from EricWF/constinit.md
A Proposal to allow constexpr(<expr>) in expression context to force compile-time evaluation of expressions in C++
Document Number: Pxxxxxx (not yet)
Date: 2019-03-23
Project: Programming Language C++, Evolution
Revises: P1143r2
Reply to:

constexpr(<expr>) in expression context

#![feature(macro_rules)]
macro_rules! active_match {
//Single zero parameter case
($m:expr, $i:ident() => $b:block) => {
match $i($m) {
Some(()) => $b,
_ => panic!("Encountered an unmatched active case.")
}
};
#![allow(unused_mut, non_camel_case_types, dead_code, unused_variables, non_upper_case_globals, non_snake_case, unused_imports)]
#![feature(optin_builtin_traits, /*unboxed_closures*/, associated_consts)]
use std::fmt::{self, Debug};
use std::ops::Add;
use std::convert::{self, Into, From};
/*macro_rules! using {
[ $pp:path : ( $($elem:ident),* )
use std::default::Default;
use std::sync::mpsc::{Receiver, Sender, channel};
struct Wrap<T>(T);
macro_rules! ident_zip_signal {
( () ; ( $($id: ident,)* ) ; ( $($idr:ident: $tyr:ty,)* ) ) => {
fn signal( &mut self, $($idr : $tyr,)* ) {
for f in self.s.iter_mut() {
f($($idr),*);
#![allow(unused_mut, non_camel_case_types, dead_code, unused_variables)]
use std::fmt::{self, Debug};
use std::ops::Add;
/*macro_rules! using {
[ $pp:path : ( $($elem:ident),* )
] => [
use $pp :: {self, $(elem),*};
];
#![allow(unused_mut, non_camel_case_types, dead_code, unused_variables)]
#![feature(trace_macros)]
use std::fmt::{self, Debug};
/*macro_rules! using {
[ $pp:path : ( $($elem:ident),* )
] => [
use $pp :: {self, $(elem),*};
];
#![allow(non_camel_case_types, unused_variables, dead_code, unused_mut)]
#![feature(concat_idents, trace_macros)]
//#![feature(struct_inherit)]
macro_rules! cc { () => () }
macro_rules! vv {
[ ( $($first:expr),+ ) : $func:ident $($rest:tt)*
] => [
cc! { [ $func( $($first),+ ) ] # $($rest)*; }