Skip to content

Instantly share code, notes, and snippets.

View Mahdisadjadi's full-sized avatar

mahdi sadjadi Mahdisadjadi

View GitHub Profile
import numpy as np
from numpy.linalg import matrix_power
from matplotlib import pyplot as plt
import seaborn as sns
SIZE = 100
M = np.zeros((SIZE, SIZE))
# encoding rolls of die
for y in xrange(SIZE):
@Mahdisadjadi
Mahdisadjadi / structure-of-tweepy-status-object.json
Created December 12, 2017 17:00
the structure of the Status object of Tweepy
/* json.dumps(StatusObject._json) */
{
"created_at": "Thu Jul 28 00:08:39 +0000 2016",
"in_reply_to_status_id": null,
"id_str": "758454081656467456",
"retweeted": false,
"entities": {
"hashtags": [
{
@Mahdisadjadi
Mahdisadjadi / 2D_periodic_box.py
Last active September 19, 2017 01:58
Image of a general periodic box with two atoms in the unit cell
import matplotlib.pyplot as plt
from itertools import product
import numpy as np
a,b = np.array([4,1]),np.array([1,3])
fig,ax = plt.subplots(1,1,figsize=(5,5))
ax.set_xlim(-6,8)
ax.set_ylim(-6,8)
ax.set_axis_off()
@Mahdisadjadi
Mahdisadjadi / set_verbs_arxiv.py
Created September 12, 2017 16:50
Generate the list of categories on arxiv.org
from bs4 import BeautifulSoup
import requests
url = 'http://export.arxiv.org/oai2?verb=ListSets'
def return_soup(url):
url = requests.get(url).content
soup = BeautifulSoup(url,"html.parser")
return soup
def get_namespace(x):
name = x.find('setspec').text
tag = x.find('setname').text
@Mahdisadjadi
Mahdisadjadi / arxiv_categories.py
Created June 9, 2017 06:37
Make a markdown table from categories and subcategories of Arxiv.org
from bs4 import BeautifulSoup
import requests
# url to scrape
cat_url = 'https://arxiv.org/'
subcat_url = 'https://arxiv.org/archive/'
def return_soup(url):
url = requests.get(url).content
soup = BeautifulSoup(url,"html.parser")
return soup
@Mahdisadjadi
Mahdisadjadi / add_text_before_extension.sh
Created May 27, 2017 17:17
Adding text to filename before extension
#!/bin/bash
# Add a string to the filename before extension
# original files : results_001.pkl results_002.pkl ...
# target files: results_001_output.pkl results_001_output.pkl ...
for x in *.pkl
do
mv "$x" "${x%.pkl}_output.pkl"
done
@Mahdisadjadi
Mahdisadjadi / f2pyExample.ipynb
Created October 24, 2016 21:05 — forked from shane5ul/f2pyExample.ipynb
A jupyter notebook which demonstrates the use of f2py for computing radial distribution functions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mahdisadjadi
Mahdisadjadi / html_remover.py
Last active October 22, 2016 23:28
To remove ".html" from all links within html pages - I wrote this to fix this issue: https://github.com/emckiernan/whyopenresearch/issues/5
import codecs # to read html
from bs4 import BeautifulSoup # to parse html
import glob # to find all files with a pattern
pages = glob.glob("*.html")
for page in pages:
# loop through all files
name = page.split(".")[0]
print (name)
html=codecs.open(page, 'r') # read html
@Mahdisadjadi
Mahdisadjadi / Self-Consistent Density Functional Theory Calculations with Quantum ESPRESSO.ipynb Silicon, Aluminum, Iron, and Graphene are characterized with a popular Fortran implementation of the self-consistent density functional theory -- Quantum ESPRESSO. An introduction to DFT and using QE is given, and results for Silicon are compared with those of previous calculations using the empirical pseudopotential and tight-binding methods.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mahdisadjadi
Mahdisadjadi / Tight-Binding Calculation of the Band Structure of Silicon.ipynb The band structure of Silicon is calculated using the empirical tight-binding method implemented in the Python programming language. Only interactions between first nearest neighbors are taken into account. The energy splittings for Silicon at symmetry points appear to be somewhat accurate to accepted values, although second neighbors will have …
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.