Skip to content

Instantly share code, notes, and snippets.

View mcnakhaee's full-sized avatar

Muhammad Chenariyan Nakhaee mcnakhaee

View GitHub Profile
@mcnakhaee
mcnakhaee / lzw.py
Created February 15, 2022 22:35 — forked from BertrandBordage/lzw.py
Lempel-Ziv-Welch algorithm in Python
from math import floor, ceil
from typing import AnyStr
ASCII_TO_INT: dict = {i.to_bytes(1, 'big'): i for i in range(256)}
INT_TO_ASCII: dict = {i: b for b, i in ASCII_TO_INT.items()}
def compress(data: AnyStr) -> bytes:
if isinstance(data, str):
@mcnakhaee
mcnakhaee / github_contributions_echarts4r.r
Last active October 21, 2020 21:57
Collect your Github contributions data and plot them with echarts4r
# Heavily inspired by https://github.com/jimhester/jimhester.com/blob/433629b9ecfdc8861022492ae77438cabb5273f3/content/home/graph.R
library(tidyverse)
library(rvest)
library(echarts4r)
library(lubridate)
github_data <- function(from = to - years(1), to = today(), user = "mcnakhaee") {
html <- xml2::read_html(str_glue("https://github.com/users/{user}/contributions?from={from}&to={to}&tab=overview"))
calendar <- html_node(html, ".js-calendar-graph-svg")
calendar_days <- html_nodes(calendar, "rect")
@mcnakhaee
mcnakhaee / tidygraph_echarts4r.r
Last active October 20, 2020 19:18
tidygraph and echarts4r
plot_interactive_graph <- function(data){
graph_edges_tbl <- data %>%
rename(from = source, to = target)
ggraph_df <- graph_edges_tbl %>%
as_tbl_graph(directed = FALSE) %>%
activate(nodes) %>%
mutate(
centrality_degree = centrality_degree(),
data %>%
count(from = item1,to = item2) %>%
select(from,to,n) %>%
as_tbl_graph(directed = FALSE) %>%
ggraph(layout = "kk") +
geom_edge_link(aes(edge_width = n,alpha = n,colour = n)) +
geom_node_label(aes(label = name),size = 4,repel = TRUE,family = 'Rubik') +
geom_node_point(size = 5)
@mcnakhaee
mcnakhaee / hyperband.py
Created December 20, 2019 13:47 — forked from PetrochukM/hyperband.py
Here we implement hyperband and successive halving adaptions. We found that the original hyperband implementation was messy and not tested. We also wanted to adapt it to include model reuse.
"""
We implement additional hyperparameter optimization methods not present in
https://scikit-optimize.github.io/.
Gist: https://gist.github.com/Deepblue129/2c5fae9daf0529ed589018c6353c9f7b
"""
import math
import logging
import random
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Python Basics with Numpy (optional assignment)\n",
"\n",
"Welcome to your first assignment. This exercise gives you a brief introduction to Python. Even if you've used Python before, this will help familiarize you with functions we'll need. \n",
"\n",
@mcnakhaee
mcnakhaee / x.py
Created April 21, 2018 20:03
test
plt.xlabel("یک محور همینجوری",fontsize = 15)
plt.ylabel("یک محور دیگه همینجوری",fontsize = 15)
plt.title("یک نمودار همینجوری" , fontsize = 20)
plt.show()