Skip to content

Instantly share code, notes, and snippets.

View mmahmoudian's full-sized avatar
💡
See mehrad.ai for details...

Mehrad Mahmoudian mmahmoudian

💡
See mehrad.ai for details...
View GitHub Profile
venn_zones <- function(lst, output = "data.frame", verbose = TRUE){
## Description:
## A function to get the items in each zone of a venn diagram when
## provided with the exact list that was given to a venn::venn().
##
## Arguments:
## lst: The exact list that was given to a venn::venn()
## output: The format that the output should be returned. Valid options are
## "data.frame" and "list".
## verbose: If the function should show which zone it is working on
@mmahmoudian
mmahmoudian / which_square_of_sums.R
Last active December 16, 2019 13:56
if you treat the number as a string and break it at some point(s), the square of sums should be equal to the number.
################################################################################
## This code is in response to the following tweet of "Fermat's Library" ##
## https://twitter.com/fermatslibrary/status/1180837639915819008?s=20 ##
## ##
## It is also corresponsing to the following entry in the On-Line ##
## Encyclopedia of Integer Sequences (OEIS): ##
## https://oeis.org/search?q=A104113 ##
## ##
## Author: Mehrad Mahmoudian ##
## License: GPL3 ##
@mmahmoudian
mmahmoudian / palette.R
Last active December 29, 2022 00:40
A function to select distinctive colors for plotting
# A function to select distinctive colors for plotting
palette <- function(x = NULL, show = FALSE){
## Arguments:
## x: Either the number of colors you need (which it will return the
## pallet with the similar or more colors), or the name of the
## palette you want. leave empty to get the catalogue.
##
## show: Set to TRUE if you want to see a specific palette.
#-------[ color palettes ]-------#
@mmahmoudian
mmahmoudian / view.sh
Created September 11, 2017 10:56
A code to make life easier for those who want to view the data with different delimiters in terminal, even with massive files.
#!/bin/bash
#
# This file is useful for those who work in data science. For those
# who want to view the data with different delimiters in terminal.
# for those who have massive datasets and need to view some first
# few lines.
#
# Author: Mehrad Mahmoudian
# Contact:
# email: m[dot]mahmoudian[at]gmail[dot]com
@mmahmoudian
mmahmoudian / git-wars.md
Last active April 5, 2017 13:32 — forked from juderosen/git-wars.md
Git Wars: GitHub vs Bitbucket

Git Wars: GitHub vs Bitbucket

Introduction

Now, you might think the answer I'm going to give you is already obvious because I'm using GiHub right now, but it's not. Both GitHub and Bitbucket offer great Git services, but each has its own features and pricing plans. In the following... thing, I'm going to compare the two and then offer a final solution that should work for most people.

TL;DR: Both. Use GitHub for open source and public repos (you'll spend most of your time here) and Bitbucket for private repos. But, sign up for GitHub first, then import account into Bitbucket. Also, check comments for updates. P.S. I personally prefer GitHub.

Interface and Functionality

@mmahmoudian
mmahmoudian / vioplot2
Last active April 4, 2016 20:22 — forked from mbjoseph/vioplot2.R
Slight change to the vioplot function from Daniel Adler that plots median lines instead of points, and gives the option to plot either side of a violin rather than always both.
vioplot2 <- function (x, ..., range = 1.5, h = NULL, ylim = NULL, names = NULL,
horizontal = FALSE, col = "magenta", border = "black", lty = 1,
lwd = 1, rectCol = "black", colMed = "white", pchMed = 19,
at, add = FALSE, wex = 1, drawRect = TRUE, side="both", na.rm = TRUE)
{
datas <- list(x, ...)
n <- length(datas)
if (missing(at))
at <- 1:n
upper <- vector(mode = "numeric", length = n)
"""
Author: Mehrad Mahmoudian
Date: 17-Jan-2013
A simple assignment
"""
class CarPark:
def __init__(self, room, reserved): # Constructor
if reserved > room :
print "number of reserved parkings should not be more than total space"