Skip to content

Instantly share code, notes, and snippets.

View Mahdisadjadi's full-sized avatar

mahdi sadjadi Mahdisadjadi

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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": [
{
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 / double_well_pontential_picture.py
Created December 20, 2017 22:26
Generate a picture of a symmetric one-dimensional double-well pontetial
'''
This code generates a picture of a symmetric
one-dimensional double-well pontetial.
Mahdi Sadjadi, 2017.
'''
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter, MaxNLocator
for param in ['axes.labelsize','xtick.labelsize','ytick.labelsize']:
@Mahdisadjadi
Mahdisadjadi / specific_heat_two_level_states.py
Created December 22, 2017 01:31
Generate picture of a specific heat two level states
'''
This code generates a picture of the specific
heat of a two-level system. It also shows
the limits in low- and high-temperatures
regions, in addition to the location of
the maximum specific heat.
Mahdi Sadjadi, 2017.
'''
import numpy as np
@Mahdisadjadi
Mahdisadjadi / queue_python.py
Last active February 24, 2018 21:13
A simple implementation of Queue data structure in python
# A simple implementation of Queue data structure in python
# FIFO: first (item) in, first (item) out
# Insert at the front, pop at the end of the list
class Queue():
def __init__(self):
self.items = []
def isEmpty(self):